标签:des style blog http color java os io
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 6499 Accepted Submission(s): 3874
1 #include<cstdio> 2 #include<cstring> 3 #include<stdlib.h> 4 #include<algorithm> 5 using namespace std; 6 struct node 7 { 8 int day; 9 int num; 10 bool operator<(const node &B)const 11 { 12 if(num!=B.num) 13 return num>B.num; 14 else 15 return day<B.day; 16 } 17 }a[1000]; 18 int vis[1000]; 19 int main() 20 { 21 int kase; 22 scanf("%d",&kase); 23 while(kase--) 24 { 25 int n,i,j,sum=0,ans=0; 26 memset(vis,0,sizeof(vis)); 27 scanf("%d",&n); 28 for(i=1;i<=n;i++) 29 scanf("%d",&a[i].day); 30 for(i=1;i<=n;i++) 31 scanf("%d",&a[i].num); 32 sort(a+1,a+n+1); 33 for(i=1;i<=n;i++) 34 { 35 for(j=a[i].day;j>0;j--) 36 { 37 if(!vis[j]) 38 { 39 vis[j]=1; 40 break; 41 } 42 } 43 if(j==0) 44 ans+=a[i].num; 45 } 46 printf("%d\n",ans); 47 } 48 return 0; 49 }
HDU 1789 Doing Homework again (贪心),布布扣,bubuko.com
HDU 1789 Doing Homework again (贪心)
标签:des style blog http color java os io
原文地址:http://www.cnblogs.com/clliff/p/3898483.html