답안 #1087069

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1087069 2024-09-12T07:21:25 Z toast12 Med (COCI22_med) C++14
10 / 50
1 ms 348 KB
#include <bits/stdc++.h>
using namespace std;

bool compare(pair<int, string> a, pair<int, string> b) {
    return (a.first == b.first ? a.second < b.second : a.first > b.first);
}

int main() {
    int n;
    cin >> n;
    vector<pair<int, string>> people(n);
    for (int i = 0; i < n; i++) {
        cin >> people[i].second;
        for (int j = 0; j < 5; j++) {
            int x;
            cin >> x;
            people[i].first += x;
        }
    }
    vector<pair<int, string>> temp = people;
    sort(people.begin(), people.end(), compare);
    vector<pair<int, int>> ans(n);
    for (int i = 0; i < n; i++) {
        int a = n;
        for (int j = 0; j < n; j++) {
            if (j == i) continue;
            if (people[j].first < people[i].first+500) {
                if (j < i) a = j+1;
                else a = j;
                break;
            }
            else if (people[j].first == people[i].first+500) {
                if (people[i].second < people[j].second) {
                    if (j < i) a = j+1;
                    else a = j;
                }
                else {
                    if (j < i) a = j+2;
                    else a = j+1;
                }
                break;
            }
        }
        int b = a;
        for (int j = n-1; j >= 0; j--) {
            if (j == i) continue;
            if (people[j].first+500 > people[i].first) {
                if (j < i) b = j+2;
                else b = j+1;
                break;
            }
            else if (people[j].first+500 == people[i].first) {
                if (people[i].second < people[j].second) {
                    if (j < i) b = j+1;
                    else b = j;
                }
                else {
                    if (j < i) b = j+2;
                    else b = j+1;
                }
                break;
            }
        }
        ans[i] = {a, b};
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (temp[i].second == people[j].second) {
                cout << ans[j].first << ' ' << ans[j].second << '\n';
                break;
            }
        }
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 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
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 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 Incorrect 1 ms 344 KB Output isn't correct
6 Halted 0 ms 0 KB -