結果

問題 No.1705 Mode of long array
ユーザー eve__fuyuki
提出日時 2024-04-13 13:49:19
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 244 ms / 3,000 ms
コード長 810 bytes
コンパイル時間 2,227 ms
コンパイル使用メモリ 201,080 KB
最終ジャッジ日時 2025-02-21 01:01:58
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 51
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
}

int main() {
    fast_io();
    long long n, m;
    cin >> n >> m;
    vector<long long> a(m);
    set<pair<long long, int>> st;
    for (int i = 0; i < m; i++) {
        cin >> a[i];
        st.insert({a[i], i});
    }
    int q;
    cin >> q;
    for (; q--;) {
        int t, x;
        long long y;
        cin >> t >> x >> y;
        x--;
        if (t == 1) {
            st.erase({a[x], x});
            a[x] += y;
            st.insert({a[x], x});
        }
        if (t == 2) {
            st.erase({a[x], x});
            a[x] -= y;
            st.insert({a[x], x});
        }
        if (t == 3) {
            cout << (*st.rbegin()).second + 1 << "\n";
        }
    }
}
0