제출 #1185212

#제출 시각아이디문제언어결과실행 시간메모리
1185212Haciyev12Med (COCI22_med)C++20
0 / 50
0 ms524 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;
}

void solve(){
    ll t;
    cin >> t;
    string s[t];
    vector<pair<ll,string>>v;
    ll x ;
    ll j = 0;
    for(int j = 0; j < t; j++){
        cin >> s[j];

        ll sum = 0;

        for(int i = 0; i < 5; i++){
            cin >> x;
            sum += x;
        }
        v.pb({sum,s[j]});
      
    }

    sort(all(v));

    ll in;
    map<string,pair<ll,ll>>mp;
    for(int i = 0; i < v.size(); i++){
        ll score = v[i].F + 500;
        in = i;
        vector<pair<ll,string>>now;
        for(int j =0; j < v.size(); j++){
           if(j == i){
            now.pb({ - (v[j].F + 500), v[j].S});
           }
           else{
            now.pb({-v[j].F, v[j].S});
           }
        }

        sort(all(now));
        
        for (int rank = 0; rank < t; rank++) {
            string name = now[rank].S;
            ll currank = rank + 1;

            if (mp.find(name) == mp.end()) {
                mp[name] = {currank, currank};
            } else {
                mp[name].F = min(mp[name].F, currank); 
                mp[name].S = max(mp[name].S, currank); 
            }
        }

        

      
    }

    vector<pii>ans;
    for(int i = 0; i < t; i++){
       // cout << mp[s[i]].F << " " << mp[s[i]].S << endl;
        ans.pb({mp[s[i]].F, mp[s[i]].S});
    }

    sort(all(ans));

    for(auto i : ans){
        cout << i.F << " "<< i.S << endl;
    }

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