标签:javabean ati ret contain eal script NPU otto case
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 105467 Accepted Submission(s): 36835
#include <iostream> #include <stdio.h> #include <algorithm> using namespace std; struct dat { int j; int f; double sc; } data[1000]; bool cmp(dat a, dat b) { return a.sc>b.sc; } int main() { int m,n; double ans; while(scanf("%d%d",&m,&n) && m!=-1 && n!=-1) { for(int i=0; i<n; i++) { scanf("%d%d",&data[i].j, &data[i].f); data[i].sc = (double)data[i].j/(double)data[i].f; } sort(data, data+n, cmp); ans = 0; for(int i=0; i<n; i++) { if(data[i].f<=m) { ans+=data[i].j; m-=data[i].f; } else { ans+=data[i].sc*(double)m; break; } } printf("%.3f\n", ans); } return 0; }
标签:javabean ati ret contain eal script NPU otto case
原文地址:https://www.cnblogs.com/Dawn-bin/p/10796769.html