This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
string s[505];
int b[505][10];
int tot[505];
int n;
int idx[505];
bool cmp (const int& x, const int& y) {
if (tot[x] != tot[y])
return tot[x] > tot[y];
return s[x] < s[y];
}
int find_best (int cur_idx) {
tot[cur_idx] += 500;
sort(idx + 1, idx + 1 + n, cmp);
tot[cur_idx] -= 500;
for (int i = 1; i <= n; i++) {
if (idx[i] == cur_idx) {
return i;
}
}
}
int find_worst (int cur_idx) {
for (int i = 1; i <= n; i++) {
if (i != cur_idx)
tot[i] += 500;
}
sort(idx + 1, idx + 1 + n, cmp);
for (int i = 1; i <= n; i++) {
if (i != cur_idx)
tot[i] -= 500;
}
for (int i = 1; i <= n; i++) {
if (idx[i] == cur_idx) {
return i;
}
}
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> s[i];
for (int j = 1; j <= 5; j++) {
cin >> b[i][j];
tot[i] += b[i][j];
}
idx[i] = i;
}
for (int i = 1; i <= n; i++) {
// iota(idx + 1, idx + 1 + n, 1);
// for (int j = 1; j <= n; j++)
// cout << idx[j] << " ";
// cout << "done" << endl;
cout << find_best(i) << " " << find_worst(i) << '\n';
}
return 0;
}
Compilation message (stderr)
Main.cpp: In function 'int find_best(int)':
Main.cpp:26:1: warning: control reaches end of non-void function [-Wreturn-type]
26 | }
| ^
Main.cpp: In function 'int find_worst(int)':
Main.cpp:43:1: warning: control reaches end of non-void function [-Wreturn-type]
43 | }
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |