結果

問題 No.1705 Mode of long array
ユーザー srjywrdnprkt
提出日時 2023-06-03 16:17:28
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 307 ms / 3,000 ms
コード長 873 bytes
コンパイル時間 1,077 ms
コンパイル使用メモリ 112,456 KB
最終ジャッジ日時 2025-02-13 22:23:02
ジャッジサーバーID
(参考情報)
judge2 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 51
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <numeric>
#include <deque>
#include <complex>
#include <cassert>

using namespace std;
using ll = long long;

int main(){

    ll N, M, Q, t, x, y;
    cin >> N >> M;
    vector<ll> cnt(M+1);
    multiset<pair<ll, ll>> st;
    for (int i=1; i<=M; i++) cin >> cnt[i];

    for (int i=1; i<=M; i++) st.insert({cnt[i], i});
    cin >> Q;
    while(Q){
        Q--;
        cin >> t >> x >> y;
        if (t == 1){
            st.erase({cnt[x], x});
            cnt[x] += y;
            st.insert({cnt[x], x});
        }
        else if (t == 2){
            st.erase({cnt[x], x});
            cnt[x] -= y;
            st.insert({cnt[x], x});
        }
        else cout << st.rbegin()->second << endl;
    }

    return 0;
}
0