結果

問題 No.1705 Mode of long array
ユーザー hitonanode
提出日時 2021-10-08 23:18:10
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 211 ms / 3,000 ms
コード長 713 bytes
コンパイル時間 1,081 ms
コンパイル使用メモリ 98,620 KB
実行使用メモリ 10,368 KB
最終ジャッジ日時 2024-07-23 07:11:08
合計ジャッジ時間 7,987 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 51
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <set>
#include <utility>
#include <vector>
using namespace std;

int main() {
    cin.tie(nullptr), ios::sync_with_stdio(false);
    long long N;
    int M;
    cin >> N >> M;

    set<pair<long long, int>> se;
    vector<long long> A(M + 1);
    for (int i = 1; i <= M; ++i) {
        long long a;
        cin >> a;
        A[i] = a;
        se.emplace(a, i);
    }
    int Q;
    cin >> Q;
    while (Q--) {
        int t, x;
        long long y;
        cin >> t >> x >> y;
        se.erase(make_pair(A[x], x));
        if (t == 1) A[x] += y;
        if (t == 2) A[x] -= y;
        se.insert(make_pair(A[x], x));
        if (t == 3) cout << prev(se.end())->second << '\n';
    }
}
0