답안 #847069

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
847069 2023-09-09T05:55:22 Z Pacybwoah Med (COCI22_med) C++17
50 / 50
87 ms 456 KB
#include<iostream>
#include<string>
#include<algorithm>
#include<utility>
using namespace std;
bool cmp(pair<string,int> a,pair<string,int> b){
    if(a.second==b.second) return a.first<b.first;
    return a.second>b.second;
}
int main(){
    int n;
    cin>>n;
    vector<pair<string,int> > vec(n);
    for(int i=0;i<n;i++){
        cin>>vec[i].first;
        int sum=0,tmp;
        for(int i=0;i<5;i++) cin>>tmp,sum+=tmp;
        vec[i].second=sum;
    }
    for(int i=0;i<n;i++){
        vector<pair<string,int> > s=vec;
        s[i].second+=500;
        sort(s.begin(),s.end(),cmp);
        for(int j=0;j<n;j++){
            if(s[j].first==vec[i].first){
                cout<<j+1<<' ';
                s[j].second-=1000;
                break;
            }
        }
        sort(s.begin(),s.end(),cmp);
        for(int j=0;j<n;j++){
            if(s[j].first==vec[i].first){
                cout<<j+1<<'\n';
                break;
            }
        }
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 41 ms 344 KB Output is correct
6 Correct 81 ms 456 KB Output is correct
7 Correct 48 ms 344 KB Output is correct
8 Correct 87 ms 344 KB Output is correct
9 Correct 24 ms 348 KB Output is correct