답안 #936959

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
936959 2024-03-03T06:16:43 Z 089487 Med (COCI22_med) C++14
50 / 50
39 ms 19256 KB
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("sse4,abm,avx,popcnt")
#include<bits/stdc++.h>
#define int long long
#define quick ios::sync_with_stdio(0);cin.tie(0);
#define rep(x,a,b) for(int x=a;x<=b;x++)
#define repd(x,a,b) for(int x=a;x>=b;x--)
#define F first
#define S second
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define all(x) x.begin(),x.end()
#define sz(x) (int)(x.size())
#define lowbit(x) (x&-x)
using namespace std;
typedef pair<int,int> pii;
void debug(){
    cout<<"\n";
}
template<class T,class ...U>
void debug(T a,U ...b){
    cout<<a<<" ",debug(b...);
}
const int N=2e5+7;
const int INF=1e18L;
pair<pair<int,string>,int> v[N];
pair<pair<int,string>,int> v2[N];
bool cmp(pair<pair<int,string> ,int> &a,pair<pair<int,string>,int > &b){
    if(a.F.F!=b.F.F){
        return a.F.F>b.F.F;
    }
    return a.F.S<b.F.S;
}
signed main(){
    quick
    int n;
    cin>>n;
    rep(i,1,n){
        cin>>v[i].F.S;
        rep(t,1,5){
            int k;
            cin>>k;
            v[i].F.F+=k;
        }
        v[i].S=i;
    }
    rep(i,1,n){
        rep(j,1,n){
            v2[j]=v[j];
            if(j!=i) v2[j].F.F+=500;
        }
        sort(v2+1,v2+n+1,cmp);
        int worst=0;
        rep(j,1,n){
            if(v2[j].S==i) {
                worst=j;
                break;
            }
        }
        rep(j,1,n){
            v2[j]=v[j];
            if(j==i) v2[j].F.F+=500;
        }
        sort(v2+1,v2+n+1,cmp);
        int best=0;
        rep(j,1,n){
            if(v2[j].S==i) {
                best=j;
                break;
            }
        }
        cout<<best<<" "<<worst<<"\n";
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 19036 KB Output is correct
2 Correct 5 ms 19036 KB Output is correct
3 Correct 5 ms 19036 KB Output is correct
4 Correct 4 ms 19036 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 19036 KB Output is correct
2 Correct 5 ms 19036 KB Output is correct
3 Correct 5 ms 19036 KB Output is correct
4 Correct 4 ms 19036 KB Output is correct
5 Correct 23 ms 19036 KB Output is correct
6 Correct 34 ms 19256 KB Output is correct
7 Correct 23 ms 19036 KB Output is correct
8 Correct 39 ms 19032 KB Output is correct
9 Correct 14 ms 19252 KB Output is correct