이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |