結果

問題 No.1705 Mode of long array
ユーザー srjywrdnprktsrjywrdnprkt
提出日時 2023-01-16 17:37:18
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 309 ms / 3,000 ms
コード長 953 bytes
コンパイル時間 1,362 ms
コンパイル使用メモリ 114,940 KB
実行使用メモリ 10,312 KB
最終ジャッジ日時 2023-08-30 00:47:20
合計ジャッジ時間 16,473 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 4 ms
4,380 KB
testcase_04 AC 3 ms
4,380 KB
testcase_05 AC 4 ms
4,380 KB
testcase_06 AC 10 ms
4,384 KB
testcase_07 AC 13 ms
4,384 KB
testcase_08 AC 12 ms
4,380 KB
testcase_09 AC 10 ms
4,384 KB
testcase_10 AC 10 ms
4,380 KB
testcase_11 AC 10 ms
4,384 KB
testcase_12 AC 11 ms
4,380 KB
testcase_13 AC 223 ms
8,520 KB
testcase_14 AC 149 ms
6,140 KB
testcase_15 AC 128 ms
4,380 KB
testcase_16 AC 163 ms
4,384 KB
testcase_17 AC 113 ms
4,388 KB
testcase_18 AC 93 ms
4,380 KB
testcase_19 AC 190 ms
5,272 KB
testcase_20 AC 113 ms
4,764 KB
testcase_21 AC 171 ms
7,720 KB
testcase_22 AC 263 ms
9,720 KB
testcase_23 AC 107 ms
4,384 KB
testcase_24 AC 108 ms
4,380 KB
testcase_25 AC 106 ms
4,380 KB
testcase_26 AC 106 ms
4,384 KB
testcase_27 AC 107 ms
4,380 KB
testcase_28 AC 107 ms
4,380 KB
testcase_29 AC 107 ms
4,380 KB
testcase_30 AC 107 ms
4,380 KB
testcase_31 AC 107 ms
4,384 KB
testcase_32 AC 107 ms
4,380 KB
testcase_33 AC 292 ms
10,152 KB
testcase_34 AC 295 ms
10,128 KB
testcase_35 AC 300 ms
10,100 KB
testcase_36 AC 309 ms
10,156 KB
testcase_37 AC 295 ms
10,096 KB
testcase_38 AC 290 ms
10,152 KB
testcase_39 AC 294 ms
10,184 KB
testcase_40 AC 296 ms
10,312 KB
testcase_41 AC 292 ms
10,148 KB
testcase_42 AC 292 ms
10,172 KB
testcase_43 AC 251 ms
10,160 KB
testcase_44 AC 252 ms
10,116 KB
testcase_45 AC 258 ms
10,184 KB
testcase_46 AC 255 ms
10,168 KB
testcase_47 AC 252 ms
10,108 KB
testcase_48 AC 251 ms
10,100 KB
testcase_49 AC 239 ms
10,096 KB
testcase_50 AC 240 ms
10,168 KB
testcase_51 AC 239 ms
10,160 KB
testcase_52 AC 239 ms
10,140 KB
testcase_53 AC 243 ms
10,096 KB
権限があれば一括ダウンロードができます

ソースコード

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;

int main(){

    long long N, M, X, Y, T, Q, A, idx;
    cin >> N >> M;
    vector<long long> cnt(M+1);
    multiset<pair<long long, long long>> st;
    for (int i=1; i<=M; i++){
        cin >> A;
        cnt[i] = A;
        st.insert({A, i});
    }

    cin >> Q;
    for (int i=0; i<Q; i++){
        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 if (T == 3){
            tie(A, idx) = *st.rbegin();
            cout << idx << endl;
        }
    }

    return 0;
}
0