답안 #967391

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
967391 2024-04-22T04:09:27 Z Isam Med (COCI22_med) C++17
50 / 50
34 ms 504 KB
#include<bits/stdc++.h>
using namespace std;

int n;

int sm[501];
string s[501];

vector<pair<int, string>> em;

pair<int, int> get(int i){
	
	em.clear();
	
	pair<int, int> res;
	
	for(register int j = 1; j <= n; ++j){
		em.emplace_back(pair<int, string>{sm[j] + (i!=j?-500:0), s[j]});
	}
	
		
	sort(em.begin(), em.end());
		
	res.first = distance(em.begin(), find(em.begin(), em.end(), pair<int, string>{sm[i], s[i]})) + 1;
	
	em.clear();
	
	for(register int j = 1; j <= n; ++j){
		em.emplace_back(pair<int, string>{sm[j] + (i==j?-500:0), s[j]});
	}
	
		
	sort(em.begin(), em.end());
		
	res.second = distance(em.begin(), find(em.begin(), em.end(), pair<int, string>{sm[i] - 500, s[i]})) + 1;
	
	
	return res;
}

signed main(){
	cin >> n;
	for(register int i = 1; i <= n; ++i){
		cin >> s[i];
		for(register int j = 1, a; j <= 5; ++j){
			cin >> a;
			sm[i] += a;
		}
		sm[i] *= -1;
	}
	
	for(register int i = 1; i <= n; ++i){
		
		pair<int, int> ou = get(i);
		
		cout << ou.second <<  ' ' << ou.first << '\n';
		
	}
	
	return 0;
}

Compilation message

Main.cpp: In function 'std::pair<int, int> get(int)':
Main.cpp:17:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   17 |  for(register int j = 1; j <= n; ++j){
      |                   ^
Main.cpp:28:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   28 |  for(register int j = 1; j <= n; ++j){
      |                   ^
Main.cpp: In function 'int main()':
Main.cpp:43:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   43 |  for(register int i = 1; i <= n; ++i){
      |                   ^
Main.cpp:45:20: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   45 |   for(register int j = 1, a; j <= 5; ++j){
      |                    ^
Main.cpp:45:27: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   45 |   for(register int j = 1, a; j <= 5; ++j){
      |                           ^
Main.cpp:52:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   52 |  for(register int i = 1; i <= n; ++i){
      |                   ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 15 ms 348 KB Output is correct
6 Correct 30 ms 504 KB Output is correct
7 Correct 18 ms 344 KB Output is correct
8 Correct 34 ms 344 KB Output is correct
9 Correct 9 ms 344 KB Output is correct