Submission #1087066

# Submission time Handle Problem Language Result Execution time Memory
1087066 2024-09-12T07:14:57 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;
            }
        }
        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;
            }
        }
        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;
}
# Verdict Execution time Memory 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
# Verdict Execution time Memory 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 348 KB Output isn't correct
6 Halted 0 ms 0 KB -