제출 #660236

#제출 시각아이디문제언어결과실행 시간메모리
660236berrMed (COCI22_med)C++17
10 / 50
69 ms340 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long
int cmp(pair<int, string> x, pair<int, string> y)
{
    if(x.first<y.first) return 1;
    if(x.first==y.first&&x.second<y.second) return 1;
    return 0;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    

    int n; cin>>n;
    vector<int> tot(n);
    vector<string> s(n);

    for(int i=0; i<n; i++)
    {
        cin>>s[i];
        for(int l=0; l<5; l++)
        {
            int x; cin>>x;
            tot[i]+=x;
        }
    }
    reverse(s.begin(),s.end());

    for(int i=0; i<n; i++)
    {
        vector<pair<int, string>> q, p;

        for(int l=0; l<n; l++)
        {
            if(i==l) q.push_back({tot[l]+500, s[i]});
            else q.push_back({tot[l], s[l]});
        }

        sort(q.begin(), q.end(), cmp);
        int r=0;

        for(int l=0; l<n; l++)
        {
            if(q[l].second==s[i]) r=n-l;
        }

        for(int l=0; l<n; l++)
        {
            if(i==l) p.push_back({tot[l], s[i]});
            else p.push_back({tot[l]+500, s[l]});
        }

        sort(p.begin(), p.end(), cmp);
        int j=0;

        for(int l=0; l<n; l++)
        {
            if(p[l].second==s[i]) j=n-l;
        }

        cout<<r<<" "<<j<<"\n";


    }

}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...