Submission #1185237

#TimeUsernameProblemLanguageResultExecution timeMemory
1185237Haciyev12Med (COCI22_med)C++20
50 / 50
33 ms528 KiB
#include "bits/stdc++.h"
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define pb push_back
#define in insert
#define F first
#define S second
#define vll vector<ll>
#define all(v) v.begin(),v.end()
#define rep(a, b, c) for (int(a) = (b); (a) < (c); (a)++)//i, 0, n
#define endl '\n'
#define pii pair<ll,ll>
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
using namespace std;
const ll INF = 1e18, mod = 1e9 + 7, N = 3e5 + 5;
ll gcd(ll a, ll b) {
    return b == 0 ? a : gcd(b, a % b);
}
ll lcm(ll a, ll b) {
    return (a / gcd(a, b)) * b;
}
ll modpow(ll a, ll b){
    ll ans = 1;
    while(b > 0){
        if(b % 2 == 1){
            ans *= a;
            ans = ans%mod;
        }
        a *= a;
        a %= mod;
        b = b >> 1;
    }
    return ans % mod;
}
ll inv(ll a){
    return (modpow(a,mod-2)) % mod;
}
struct res {
    ll best;
    ll wor;
};
auto comp(const pair<ll, string>& a, const pair<ll, string>& b){
    if(a.F != b.F){
        return a.F > b.F;
    } 
    return a.S < b.S;
}
struct inp{

    string s;
    ll sc;
    ll index;
};
void solve(){
    ll t;
    cin >> t;
    vector<inp>st(t);
    vector<pair<ll,string>>v;
    ll x ;
    for(ll j = 0; j < t; j++){
        cin >> st[j].s;
        st[j].index = j;
        st[j].sc = 0;
        ll sum = 0;
        for(int i = 0; i < 5; i++){
            cin >> x;
            st[j].sc += x;
        }
    }
    vector<res>ans(t, {0, 0});
    for(int i = 0; i < st.size(); i++){
        
        vector<pair<ll,string>>now;
        for(int j =0; j < st.size(); j++){
           if(j == i){
            now.pb({  (st[j].sc + 500), st[j].s});
           }
           else{
            now.pb({st[j].sc, st[j].s});
           }
        }

        sort(all(now), comp);
        
        ll besin = 0;
        ll worin = 0;
        for (int rank = 0; rank < t; rank++) {
            if(now[rank].S == st[i].s){
                besin = rank + 1;
                break;
            }
        }

        now.clear();

        for(int j =0; j < st.size(); j++){
            if(j != i){
                now.pb({  (st[j].sc + 500), st[j].s});
               }
               else{
                now.pb({st[j].sc, st[j].s});
               }
         }

         sort(all(now), comp);
         for (int rank = 0; rank < t; rank++) {
            if(now[rank].S == st[i].s){
                worin = rank + 1;
                break;
            }
        }
        ans[i].best = besin;
        ans[i].wor = worin;

        
        

      
    }

    
   vector<pii>son;
    

    for(auto i : ans){
        cout << i.best << " " << i.wor << endl;
    }
    

}
int main() {
    fast;
    ll t = 1;
//    cin >> t;
    
    while (t--) {
        solve();
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...