結果
問題 | No.1705 Mode of long array |
ユーザー |
![]() |
提出日時 | 2022-12-14 09:48:11 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 411 ms / 3,000 ms |
コード長 | 876 bytes |
コンパイル時間 | 1,219 ms |
コンパイル使用メモリ | 89,504 KB |
実行使用メモリ | 18,176 KB |
最終ジャッジ日時 | 2024-11-08 01:49:25 |
合計ジャッジ時間 | 14,935 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 51 |
ソースコード
#include <iostream>#include <vector>#include <map>#include <set>using namespace std;using ll = long long;int main(){ll n, m; cin >> n >> m;vector<ll> arr(m+10);for(int i = 1; i <= m; i++) cin >> arr[i];map<ll, set<int>> mem;for(int i = 1; i <= m; i++){if(arr[i] > 0) mem[arr[i]].emplace(i);}int q; cin >> q;while(q--){ll t, x, y; cin >> t >> x >> y;if(t == 1){mem[arr[x]].erase(x);if(mem[arr[x]].size() == 0) mem.erase(arr[x]);arr[x] += y;mem[arr[x]].emplace(x);}else if(t == 2){mem[arr[x]].erase(x);if(mem[arr[x]].size() == 0) mem.erase(arr[x]);arr[x] -= y;mem[arr[x]].emplace(x);}else{cout << *mem.rbegin()->second.rbegin() << '\n';}}return 0;}