본문 바로가기

BOJ

[BOJ][C++] 백준 11098번 - 첼시를 도와줘!

728x90

문제 링크: https://www.acmicpc.net/problem/11098

 

11098번: 첼시를 도와줘!

구단이 성적을 내지 못한다면 답은 새 선수 영입뿐이다. 이것은 오늘날 유럽 리그에서 가장 흔한 전략이고, 노르웨이의 로젠버그 팀은 이러한 전략이 성공한 대표적 예시다. 그들은 많은 스카

www.acmicpc.net


문제 풀이

반복문 돌려서 값을 max로 갱신하여 이름을 갱신하자.

 

코드

#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main() {
int n, p, money, ans = -1;
string s1, s2 = "";
cin >> n;
for (int i = 0; i < n; i++){
cin >> p;
money = 0;
ans = -1;
for (int j = 0; j < p; j++){
cin >> money >> s1;
if (ans < money){
ans = money;
s2 = s1;
}
}
cout << s2 << "\n";
}
}
view raw 11098.cpp hosted with ❤ by GitHub
728x90