Submission #754656

# Submission time Handle Problem Language Result Execution time Memory
754656 2023-06-08T08:34:52 Z Trisanu_Das Med (COCI22_med) C++17
50 / 50
1 ms 340 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int n;cin>>n;
	vector<pair<int,string>> best;
	vector<pair<int,string> > worse;
	pair<string,int> score[n];
	for(int i=0;i<n;i++){
		string s;cin>>s;
		score[i].second=0;
		for(int j=0;j<5;j++){
			int a;cin>>a;
			score[i].second+=a;
		}
		score[i].first = s;
		best.push_back({-score[i].second-500,score[i].first});
		worse.push_back({-score[i].second,score[i].first});
	}
	sort(best.begin(),best.end());	
	sort(worse.begin(),worse.end());
	for(int i=0;i<n;i++){
		pair<int,string> p = {-score[i].second-500,score[i].first};
		int g = upper_bound(worse.begin(),worse.end(),p)-worse.begin();	
		cout<<g+1<<" ";
		p.first+=500;
		g = upper_bound(best.begin(),best.end(),p)-best.begin();	
		cout<<g<<"\n";	
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 316 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 316 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct