1055. 428-被封锁的涩谷

new_user_2 2024-03-11 8:55:01

  • 签到题
  • 卡了没关同步流的cin 以及莫名卡了python
  • a在本题中没有作用
  • 主要思路见下面代码即可
#include <iostream>
#include <map>
#include <unordered_map>

using namespace std;

typedef long long ll;

const int N = 1e6 + 10;
unordered_map<int, ll> mp;

int main() {
    int n, m;
    scanf("%d %d", &n, &m);
    ll mx = -1, ans;
    for (int i = 1; i <= m; i++) {
        int x, y, z;
        scanf("%d %d %d", &x, &y, &z);
        mp[y] += z;
        if (mp[y] > mx) {
            mx = mp[y];
            ans = y;
        }
    }
    cout << ans << endl;
}