标签:
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 8638 Accepted Submission(s):
5090
#include<stdio.h> #include<string.h> #include<algorithm> using namespace std; struct record { int day; int score; }num[1100]; bool cmp(record a,record b) { if(a.score!=b.score) return a.score>b.score; else return a.day<b.day; } int main() { int n,m,j,i,t,l,sum; int vis[1100];//用来储存必须要占用的日期 scanf("%d",&t); while(t--) { scanf("%d",&n); memset(vis,0,sizeof(vis)); for(i=0;i<n;i++) scanf("%d",&num[i].day); for(i=0;i<n;i++) scanf("%d",&num[i].score); sort(num,num+n,cmp); sum=0; for(i=0;i<n;i++) { for(j=num[i].day;j>=1;j--) { if(vis[j]==0) { vis[j]=1; break; } } if(j==0) sum+=num[i].score; } printf("%d\n",sum); } return 0; }
hdoj 1789 Doing Homework again
标签:
原文地址:http://www.cnblogs.com/tonghao/p/4680517.html