Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
为什么WA!我自己觉得挺好啊,都WA了N次了。。。#include<iostream> #include<cstdio> #include<algorithm> #define MAXSIZE 10000 using namespace std; struct prod{ int pi; int di; }; bool more_p(const prod &m1,const prod &m2){ return m1.pi>m2.pi; } bool less_d(const prod &m1,const prod &m2){ return m1.di<m2.di; } int main(){ struct prod P[MAXSIZE]; int n,i,sum,t_unit; while(cin>>n){ for(i=0;i<n;i++) cin>>P[i].pi>>P[i].di; sort(P,P+n,more_p); stable_sort(P,P+n,less_d); for(sum=P[0].pi,t_unit=1,i=1;i<n;i++){ if(P[i].di>t_unit){ sum+=P[i].pi; t_unit++; } } cout<<sum<<endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator