# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
872993 |
2023-11-14T08:57:52 Z |
HossamHero7 |
Med (COCI22_med) |
C++14 |
|
118 ms |
524 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
bool cmp(pair<ll,string> p1 , pair<ll,string> p2){
if(p1.first > p2.first) return 1;
if(p1.first < p2.first) return 0;
return p1.second < p2.second;
}
void solve(){
int n;
cin>>n;
vector<pair<string,array<ll,5>>> v(n);
for(int i=0;i<n;i++) {
cin>>v[i].first;
for(int j=0;j<5;j++) cin>>v[i].second[j];
}
for(int i=0;i<n;i++){
vector<pair<ll,string>> tmp;
for(int j=0;j<n;j++){
ll sum = 0;
sum += v[j].second[0];
sum += v[j].second[1];
sum += v[j].second[2];
sum += v[j].second[3];
sum += v[j].second[4];
if(j == i) sum += 500;
tmp.push_back({sum,v[j].first});
}
sort(tmp.begin(),tmp.end(),cmp);
for(int j=0;j<n;j++){
if(tmp[j].second == v[i].first) {
cout<<j+1<<' ';
break;
}
}
tmp.clear();
for(int j=0;j<n;j++){
ll sum = 0;
sum += v[j].second[0];
sum += v[j].second[1];
sum += v[j].second[2];
sum += v[j].second[3];
sum += v[j].second[4];
if(j != i) sum += 500;
tmp.push_back({sum,v[j].first});
}
sort(tmp.begin(),tmp.end(),cmp);
for(int j=0;j<n;j++){
if(tmp[j].second == v[i].first) {
cout<<j+1<<endl;
break;
}
}
}
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int t=1;
//cin>>t;
while(t--){
solve();
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 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 |
344 KB |
Output is correct |
2 |
Correct |
1 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 |
Correct |
56 ms |
348 KB |
Output is correct |
6 |
Correct |
103 ms |
520 KB |
Output is correct |
7 |
Correct |
64 ms |
348 KB |
Output is correct |
8 |
Correct |
118 ms |
524 KB |
Output is correct |
9 |
Correct |
31 ms |
348 KB |
Output is correct |