結果

問題 No.1705 Mode of long array
ユーザー miscalcmiscalc
提出日時 2021-10-08 22:38:34
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 480 ms / 3,000 ms
コード長 1,541 bytes
コンパイル時間 2,391 ms
コンパイル使用メモリ 215,312 KB
実行使用メモリ 16,032 KB
最終ジャッジ日時 2023-09-30 11:37:37
合計ジャッジ時間 16,824 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 4 ms
4,380 KB
testcase_04 AC 3 ms
4,376 KB
testcase_05 AC 4 ms
4,380 KB
testcase_06 AC 12 ms
4,376 KB
testcase_07 AC 14 ms
4,376 KB
testcase_08 AC 14 ms
4,376 KB
testcase_09 AC 12 ms
4,380 KB
testcase_10 AC 11 ms
4,380 KB
testcase_11 AC 12 ms
4,376 KB
testcase_12 AC 12 ms
4,376 KB
testcase_13 AC 324 ms
13,228 KB
testcase_14 AC 209 ms
9,260 KB
testcase_15 AC 160 ms
4,712 KB
testcase_16 AC 214 ms
5,240 KB
testcase_17 AC 143 ms
4,776 KB
testcase_18 AC 121 ms
4,884 KB
testcase_19 AC 251 ms
7,276 KB
testcase_20 AC 150 ms
6,120 KB
testcase_21 AC 251 ms
12,036 KB
testcase_22 AC 388 ms
15,068 KB
testcase_23 AC 121 ms
4,376 KB
testcase_24 AC 122 ms
4,380 KB
testcase_25 AC 122 ms
4,380 KB
testcase_26 AC 122 ms
4,380 KB
testcase_27 AC 122 ms
4,376 KB
testcase_28 AC 121 ms
4,380 KB
testcase_29 AC 121 ms
4,380 KB
testcase_30 AC 122 ms
4,380 KB
testcase_31 AC 122 ms
4,380 KB
testcase_32 AC 121 ms
4,384 KB
testcase_33 AC 472 ms
15,840 KB
testcase_34 AC 480 ms
15,868 KB
testcase_35 AC 469 ms
15,912 KB
testcase_36 AC 454 ms
15,912 KB
testcase_37 AC 455 ms
15,824 KB
testcase_38 AC 445 ms
15,804 KB
testcase_39 AC 461 ms
15,980 KB
testcase_40 AC 458 ms
15,988 KB
testcase_41 AC 457 ms
16,032 KB
testcase_42 AC 460 ms
15,836 KB
testcase_43 AC 294 ms
15,832 KB
testcase_44 AC 291 ms
15,836 KB
testcase_45 AC 289 ms
15,976 KB
testcase_46 AC 292 ms
15,840 KB
testcase_47 AC 293 ms
15,916 KB
testcase_48 AC 295 ms
15,924 KB
testcase_49 AC 347 ms
15,840 KB
testcase_50 AC 347 ms
15,824 KB
testcase_51 AC 346 ms
15,920 KB
testcase_52 AC 342 ms
15,916 KB
testcase_53 AC 348 ms
15,864 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/modint>
using namespace std;
using namespace atcoder;
//using mint = modint998244353;
using mint = modint1000000007;
using ll = long long;
using ld = long double;
using pll = pair<ll, ll>;
using tlll = tuple<ll, ll, ll>;
constexpr ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll safemod(ll A, ll M) {return (A % M + M) % M;}
ll divfloor(ll A, ll B) {if (B < 0) {return divfloor(-A, -B);} return (A - safemod(A, B)) / B;}
ll divceil(ll A, ll B) {if (B < 0) {return divceil(-A, -B);} return divfloor(A + B - 1, B);}
#define FINALANS(A) do {cout << (A) << '\n'; exit(0);} while (false) 

int main()
{
  ll N, M;
  cin >> N >> M;

  map<ll, ll> mp;
  set<pll> st;
  for (ll i = 0; i < M; i++)
  {
    ll a;
    cin >> a;
    mp[i + 1] = a;
    st.emplace(make_pair(a, i + 1));
  }

  ll Q;
  cin >> Q;
  for (ll q = 0; q < Q; q++)
  {
    ll T, X, Y;
    cin >> T >> X >> Y;

    if (T == 1)
    {
      st.erase(make_pair(mp[X], X));
      mp[X] += Y;
      st.emplace(make_pair(mp[X], X));
    }
    else if (T == 2)
    {
      st.erase(make_pair(mp[X], X));
      mp[X] -= Y;
      st.emplace(make_pair(mp[X], X));
    }
    else if (T == 3)
    {
      ll ans = (*(st.rbegin())).second;
      cout << ans << '\n';
    }

    /*
    for (auto p : st)
    {
      cerr << p.first << " " << p.second << endl;
    }
    cerr << endl;
    //*/
  }
}
0