fork(1) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. struct student{
  4. int yu,shu,ying,id,zong,yushu,yushux,idx;
  5. }arr[100000];
  6. bool cmp(student x,student y){
  7. if(x.zong==y.zong){
  8. if(x.yushu==y.yushu){
  9. return x.yushux>y.yushux;
  10. }
  11. return x.yushu>y.yushu;
  12. }
  13. return x.zong>y.zong;
  14. }
  15. bool cmp2(student x,student y){
  16. return x.idx<y.idx;
  17. }
  18. long long n;
  19. int main(){
  20. ios::sync_with_stdio(false);
  21. cin.tie(0);
  22. cout.tie(0);
  23. cin>>n;
  24. for(int i=1;i<=n;i++){
  25. cin>>arr[i].yu>>arr[i].shu>>arr[i].ying;
  26. arr[i].zong=arr[i].yu+arr[i].shu+arr[i].ying;
  27. arr[i].yushux=max(arr[i].yu,arr[i].shu);
  28. arr[i].yushu=arr[i].yu+arr[i].shu;
  29. arr[i].idx=i;
  30. }
  31. sort(arr+1,arr+n+1,cmp);
  32. arr[1].id=1;
  33. for(int i=2;i<=n;i++){
  34. if(arr[i].zong==arr[i-1].zong && arr[i].yushu==arr[i-1].yushu && arr[i].yushux==arr[i-1].yushux){
  35. arr[i].id=arr[i-1].id;
  36. }else{
  37. arr[i].id=i;
  38. }
  39. }
  40. sort(arr+1,arr+1+n,cmp2);
  41. for(int i=1;i<=n;i++){
  42. cout<<arr[i].id<<"\n";
  43. }
  44. return 0;
  45. }
Success #stdin #stdout 0.01s 5320KB
stdin
6
140 140 150
140 149 140
148 141 140
141 148 140
145 145 139
0 0 0
stdout
1
3
4
4
2
6