답안 #1103453

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1103453 2024-10-21T03:12:06 Z overwatch9 Med (COCI22_med) C++17
10 / 50
1 ms 340 KB
#include <bits/stdc++.h>
using namespace std;
vector <pair <int, string>> scores;
int main() {
    int n;
    cin >> n;
    map <string, int> mp;
    scores.resize(n);
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        scores[i].second = s;
        mp[s] = i;
        for (int j = 0; j < 5; j++) {
            int x;
            cin >> x;
            scores[i].first -= x;
        }
    }
    sort(scores.begin(), scores.end());
    vector <int> scores2(n);
    for (int i = 0; i < n; i++) {
        scores[i].first = -scores[i].first;
        scores2[n-i-1] = scores[i].first;
    }

    vector <pair <int, int>> ans(n);
    for (int i = 0; i < n; i++) {
        string name = scores[i].second;
        int id = mp[name];
        ans[id].first = n - (lower_bound(scores2.begin(), scores2.end(), scores[i].first+500) - scores2.begin() - 1);
        ans[id].second = n - (upper_bound(scores2.begin(), scores2.end(), scores[i].first-500) - scores2.begin() - 1) - 1;

    }
    for (int i = 0; i < n; i++)
        cout << ans[i].first << ' ' << ans[i].second << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Incorrect 1 ms 340 KB Output isn't correct
6 Halted 0 ms 0 KB -