結果

問題 No.1705 Mode of long array
ユーザー miscalc
提出日時 2021-10-08 22:38:34
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 531 ms / 3,000 ms
コード長 1,541 bytes
コンパイル時間 2,562 ms
コンパイル使用メモリ 207,872 KB
最終ジャッジ日時 2025-01-24 22:54:03
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 51
権限があれば一括ダウンロードができます

ソースコード

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;
//*/
}
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0