标签:scan cst img cstring logs ret long 最大的 log
1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 #include<iostream> 5 #include<cmath> 6 #include<queue> 7 using namespace std; 8 long long n; 9 struct wtff{ 10 long long d,p; 11 }wtf[100010]; 12 priority_queue< long long >q; 13 bool mycmp(wtff a,wtff b){ 14 return (a.d<b.d|| 15 (a.d==b.d&&a.p<b.p)); 16 } 17 int main(){ 18 long long ans=0; 19 cin>>n; 20 for(int i=1;i<=n;i++){ 21 scanf("%lld%lld",&wtf[i].d,&wtf[i].p); 22 } 23 sort(wtf+1,wtf+1+n,mycmp); 24 int now=0; 25 for(int i=1;i<=n;i++){ 26 ans+=wtf[i].p; 27 now++; 28 q.push(-wtf[i].p); 29 if(now>wtf[i].d){ 30 ans+=q.top(); 31 q.pop(); 32 now--; 33 } 34 } 35 cout<<ans<<endl; 36 return 0; 37 }
标签:scan cst img cstring logs ret long 最大的 log
原文地址:http://www.cnblogs.com/137shoebills/p/7783720.html