标签:
| Time Limit: 1000MS | Memory Limit: 131072KB | 64bit IO Format: %I64d & %I64u |
Description
Input
Output
Sample Input
1 4 10 110 5 9 30 2 1 80 4 8 50 3 2
Sample Output
88
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | #include<cstdio>#include<algorithm>#include<vector>#include<cstring>#include<map>using namespace std;const int maxn = 1000 + 10;struct Problem{ int A,B,C;}ps[maxn];int solved[maxn];int main(){ int T; scanf("%d",&T); while(T--) { int n,t; scanf("%d%d",&n,&t); for(int i= 0; i < n;i++) scanf("%d%d%d",&ps[i].A,&ps[i].B,&ps[i].C); memset(solved,0,sizeof(solved)); int cur = 0; int res = 0; while(cur < t) { int maxid = -1,maxscore = -1; for(int i = 0; i < n;i++) { if(!solved[i] && cur + ps[i].C <= t){ int score = ps[i].A - ps[i].B*(cur + ps[i].C); if(score > maxscore) { maxid = i; maxscore = score; } } } if(maxid == -1) break; solved[maxid] = 1; res += maxscore; cur += ps[maxid].C; } printf("%d\n",res); } return 0;} |
[2016-02-04][HDU][5501][The Highest Mark]
标签:
原文地址:http://www.cnblogs.com/qhy285571052/p/5182494.html