From e2c361566edcb97f8b7ee1c116cd2632544a433b Mon Sep 17 00:00:00 2001 From: Ren Baoshuo Date: Mon, 16 Nov 2020 19:16:41 +0800 Subject: [PATCH] CF2A Winner R42010428 --- problem/CF2A/CF2A.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 problem/CF2A/CF2A.cpp diff --git a/problem/CF2A/CF2A.cpp b/problem/CF2A/CF2A.cpp new file mode 100644 index 00000000..f91ddfcd --- /dev/null +++ b/problem/CF2A/CF2A.cpp @@ -0,0 +1,27 @@ +#include + +using namespace std; + +int main() { + int n, t, max_score = -0x3f3f3f3f; + int scores[1005]; + string s, max_player, players[1005]; + map m, m1; + cin >> n; + for (int i = 0; i < n; i++) { + cin >> players[i] >> scores[i]; + m[players[i]] += scores[i]; + } + for (int i = 0; i < n; i++) { + max_score = max(max_score, m[players[i]]); + } + for (int i = 0; i < n; i++) { + m1[players[i]] += scores[i]; + if (m[players[i]] == max_score && m1[players[i]] >= max_score) { + max_player = players[i]; + break; + } + } + cout << max_player << endl; + return 0; +}