// Problem: #1 - Med
// Contest: DMOJ - COCI '21 Contest 6
// URL: https://dmoj.ca/problem/coci21c6p1
// Memory Limit: 512 MB
// Time Limit: 1000 ms
//
// Powered by CP Editor (https://cpeditor.org)
#include <bits/stdc++.h>
using namespace std;
#define lg long long
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
bool cmp(pair<lg, string> a, pair<lg, string> b)
{
if(a.first == b.first) return a.second < b.second;
return a.first > b.first;
}
int main()
{
fastio;
lg n;
cin >> n;
vector<pair<lg, string>> v, a, b;
for(int i = 0; i < n; i++)
{
string s;
cin >> s;
lg x = 0, y = 5;
while(y--)
{
lg z;
cin >> z;
x += z;
}
v.push_back({x, s});
}
for(int i = 0; i < n; i++)
{
for(int j = 0; j < n; j++)
{
if(i == j) a.push_back({v[j].first+500, v[j].second}), b.push_back(v[j]);
else b.push_back({v[j].first+500, v[j].second}), a.push_back(v[j]);
}
sort(a.begin(), a.end(), cmp);
sort(b.begin(), b.end(), cmp);
for(int j = 0; j < n; j++)
{
if(v[i].second == a[j].second)
{
cout << j+1 << ' ';
}
if(v[i].second == b[j].second)
{
cout << j+1 << ' ';
}
}
cout << '\n';
a.clear();
b.clear();
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
344 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 |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
50 ms |
348 KB |
Output is correct |
6 |
Correct |
102 ms |
348 KB |
Output is correct |
7 |
Correct |
62 ms |
524 KB |
Output is correct |
8 |
Correct |
120 ms |
348 KB |
Output is correct |
9 |
Correct |
30 ms |
348 KB |
Output is correct |