Submission #872342

# Submission time Handle Problem Language Result Execution time Memory
872342 2023-11-12T22:36:46 Z Ahmed_Solyman Med (COCI22_med) C++14
50 / 50
125 ms 736 KB
/*
In the name of Allah
made by: Ahmed_Solyman
*/
#include <bits/stdc++.h>
#include <ext/rope>
 
using namespace std;
using namespace __gnu_cxx;
#pragma GCC optimize("-Ofast")
#pragma GCC optimize("-O1")
//-------------------------------------------------------------//
typedef long long ll;
typedef unsigned long long ull;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PI acos(-1)
#define lb lower_bound
#define ub upper_bound
#define endl '\n'
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define sum_to(n) (n*(n+1))/2
#define pb push_back
#define pf push_front
#define fil(arr,x) memset(arr,x,sizeof(arr))
const ll mod=1e9+7;
int dx[8]={0,1,0,-1,1,1,-1,-1};
int dy[8]={1,0,-1,0,1,-1,-1,1};
//-------------------------------------------------------------//
ll lcm(ll a,ll b)
{
    return (max(a,b)/__gcd(a,b))*min(a,b);
}
void person_bool(bool x)
{
    cout<<(x?"YES":"NO")<<endl;
}
bool cmp(pair<int,string> a,pair<int,string> b){
    if(a.first>b.first){
        return 1;
    }
    else if(a.first<b.first){
        return 0;
    }
    else{
        if(a.second<b.second){
            return 1;
        }
        return 0;
    }
}
int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    #ifndef ONLINE_JUDGE
    //freopen("input.in", "r", stdin);
    //freopen("output.out", "w", stdout);
    #endif
    fast
    int n;cin>>n;
    vector<pair<int,string>>v(n);
    vector<pair<int,string>>arr(n);
    for(int i=0;i<n;i++){
        string s;cin>>s;
        int sum=0;
        for(int j=0;j<5;j++){
            int x;cin>>x;
            sum+=x;
        }
        v[i]={sum,s};
        arr[i]={sum,s};
    }
    for(int i=0;i<n;i++){
        v[i].first+=500;
        sort(all(v),cmp);
        int a=0,b=0;
        for(int j=0;j<n;j++){
            if(v[j].second==arr[i].second){
                a=j;
            }
        }
        v=arr;
        for(int j=0;j<n;j++){
            if(i!=j)v[j].first+=500;
        }
        sort(all(v),cmp);
        for(int j=0;j<n;j++){
            if(v[j].second==arr[i].second){
                b=j;
            }
        }
        v=arr;
        cout<<a+1<<" "<<b+1<<endl;
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 360 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 360 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 55 ms 344 KB Output is correct
6 Correct 109 ms 480 KB Output is correct
7 Correct 65 ms 348 KB Output is correct
8 Correct 125 ms 736 KB Output is correct
9 Correct 33 ms 472 KB Output is correct