Submission #660236

# Submission time Handle Problem Language Result Execution time Memory
660236 2022-11-21T09:23:33 Z berr Med (COCI22_med) C++17
10 / 50
69 ms 340 KB
#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 time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Incorrect 69 ms 340 KB Output isn't correct
6 Halted 0 ms 0 KB -