3 solutions

  • 0
    @ 2024-12-4 23:11:24

    #include<bits/stdc++.h> using namespace std; const int N=1e4; struct student{ int yu; int shu; int xh; }; int main() { int n,i,m; cin>>n; struct student s[N],temp; for(i=1;i<=n;i++){ cin>>s[i].yu>>s[i].shu; s[i].xh=i; } for(i=1;i<n;i++){ for(m=1;m<=n-i;m++){ if(s[m].yu>s[m+1].yu){ temp=s[m]; s[m]=s[m+1]; s[m+1]=temp; } else if(s[m].yus[m+1].yu&&s[m].shu>s[m+1].shu){ temp=s[m]; s[m]=s[m+1]; s[m+1]=temp; } else if(s[m].yus[m+1].yu&&s[m].shu==s[m+1].shu){ if(s[m].xh>s[m+1].xh){ temp=s[m]; s[m]=s[m+1]; s[m+1]=temp; } } } } for(i=1;i<=n;i++){ cout<<s[i].xh<<" "; } return 0; }

    Information

    ID
    6828
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    7
    Tags
    # Submissions
    102
    Accepted
    21
    Uploaded By