链接:
典型的贪心问题,水题(又一次把1000看成了100,唉,wa一次)
#include#include using namespace std;struct homework{ int deadline; int score; int state;};int cmp(homework a,homework b){ return a.score>b.score;}homework a[1005];int visit[1005];int main(){ int t,i; cin>>t; int n,d; int sum; while(t--) { int sum=0; cin>>n; for(i=0;i >a[i].deadline; for(i=0;i >a[i].score; for(i=0;i =1;d--) { if(visit[d]==0) {visit[d]=1;a[i].state=1;break;}这里也可以不设置state变量,根据最后的d来判断也可以 } } if(a[i].state==0) sum=sum+a[i].score; } cout< <