标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 1217 Accepted Submission(s): 607
#include <iostream> #include <cstdio> #include <cstring> #include <queue> #include <algorithm> #include <math.h> using namespace std; struct Node{ int first,second,change; int id; }node[200]; int cmp(Node a,Node b){ if(a.change==b.change&&a.second==b.second) return a.id<b.id; if(a.change==b.change) return a.second<b.second; return a.change>b.change; /*if(a.change==b.change&&a.second!=b.second) return a.second<b.second; ///教训 else if(a.change==b.change&&a.second==b.second) return a.id<b.id; return a.change>b.change;*/ } int main() { int n; while(scanf("%d",&n)!=EOF){ for(int i=0;i<n;i++){ scanf("%d%d",&node[i].first,&node[i].second); node[i].change = node[i].first - node[i].second; node[i].id = i; } sort(node,node+n,cmp); for(int i=0;i<n-1;i++){ printf("%d ",node[i].id); } printf("%d\n",node[n-1].id); } return 0; }
标签:
原文地址:http://www.cnblogs.com/liyinggang/p/5687216.html