답안 #644381

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
644381 2022-09-24T14:15:39 Z Iwanttobreakfree Med (COCI22_med) C++17
50 / 50
1 ms 324 KB
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<pair<pair<int,string>,int>> bee (n);
    for (int i = 0; i < n; ++i) {
        cin >> bee[i].first.second;
        bee[i].second = i;
        for (int j = 0; j < 5; ++j){
            int x;
            cin >> x;
            bee[i].first.first -= x;
        }
    }
    sort (bee.begin(),bee.end());
    vector<pair<int,int>> ans (n);
    for (int i = 0; i < n; ++i) {
        //cout << bee[i].first.first << '\n';
        int b = i, w = i;
        for (int j = 0; j < i; ++j) {
            if (-bee[i].first.first+500 > -bee[j].first.first) {
                b = j;
                break;
            }
            if (-bee[i].first.first+500 == -bee[j].first.first and bee[i].first.second < bee[j].first.second) {
                b = j;
                break;
            }
        }
        for (int j = i+1; j < n; ++j) {
            if (-bee[i].first.first < -bee[j].first.first+500) {
                w = j;
            }
            if (-bee[i].first.first-500 == -bee[j].first.first and bee[i].first.second > bee[j].first.second) {
                w = j;
            }
        }
        ans[bee[i].second] = {b+1,w+1};
    }
    for (int i = 0; i < n; ++i) cout << ans[i].first << ' ' << ans[i].second << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 300 KB Output is correct
4 Correct 1 ms 304 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 300 KB Output is correct
4 Correct 1 ms 304 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 324 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct