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 |
为什么re。。。#include<iostream> #include<algorithm> using namespace std; struct node { int deadlie; int profie; }pro[20000]; bool cmp(node a,node b) { return a.deadlie<b.deadlie; } bool cmp2(node a,node b) { return (a.deadlie==b.deadlie&&a.profie<b.profie); } int main() { int n; while(scanf("%d",&n)!=EOF) { for(int i=0;i!=n;i++) { scanf("%d%d",&pro[i].profie,&pro[i].deadlie); } sort(pro,pro+n,cmp); sort(pro,pro+n,cmp2); /*for(int i=0;i!=n;i++) { printf("%d %d ",pro[i].profie,pro[i].deadlie); }*/ int max=pro[n-1].profie; for(int i=0;i!=n-1;i++) { if(pro[i].deadlie<pro[i+1].deadlie) { max+=pro[i].profie; } } printf("%d\n",max); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator