Submission #1185226

#TimeUsernameProblemLanguageResultExecution timeMemory
1185226Haciyev12Med (COCI22_med)C++20
0 / 50
0 ms324 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; } 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; vector<res>ans(t, {0, 0}); for(int i = 0; i < v.size(); 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), comp); ll besin = 0; ll worin = 0; for (int rank = 0; rank < t; rank++) { if(now[rank].S == v[i].S){ besin = rank + 1; break; } } now.clear(); for(int j =0; j < v.size(); j++){ if(j == i){ now.pb({ v[j].F, v[j].S}); } else{ now.pb({v[j].F + 500, v[j].S}); } } sort(all(now), comp); for (int rank = 0; rank < t; rank++) { if(now[rank].S == v[i].S){ worin = rank + 1; break; } } ans[i].best = besin; ans[i].wor = worin; } vector<pii>son; for(auto i : ans){ son.pb({i.best, i.wor}); } sort(all(son)); for(auto i : son){ 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...