Submission #1036038

#TimeUsernameProblemLanguageResultExecution timeMemory
1036038vjudge1Med (COCI22_med)C++17
50 / 50
27 ms348 KiB
#include <bits/stdc++.h>
using namespace std;

int main(){
    int n;
    cin >> n;

    vector<pair<int, string>> vec;
    for (int i = 0; i < n; i ++){
        string s;
        cin >> s;
        int sm = 0;
        for (int j = 0; j < 5; j ++){
            int x;
            cin >> x;
            sm += x;
        }

        vec.push_back({-sm, s});
    }

    for (int i = 0; i < n; i ++){
        vector<pair<int, string>> tmp;
        for (int j = 0; j < i; j ++)
            tmp.push_back(vec[j]);
        tmp.push_back({vec[i].first - 500, vec[i].second});
        for (int j = i + 1; j < n; j ++)
            tmp.push_back(vec[j]);
        sort(tmp.begin(), tmp.end());

        int pos = -1;
        for (int j = 0; j < n; j ++){
            if (tmp[j].second == vec[i].second){
                pos = j + 1;
                break;
            }
        }

        cout << pos << " ";

        tmp.clear();
        for (int j = 0; j < i; j ++)
            tmp.push_back({vec[j].first - 500, vec[j].second});
        tmp.push_back(vec[i]);
        for (int j = i + 1; j < n; j ++)
            tmp.push_back({vec[j].first - 500, vec[j].second});
        sort(tmp.begin(), tmp.end());

        pos = -1;
        for (int j = 0; j < n; j ++){
            if (tmp[j].second == vec[i].second){
                pos = j + 1;
                break;
            }
        }

        cout << pos << endl;
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...