結果

問題 No.1705 Mode of long array
コンテスト
ユーザー 沙耶花
提出日時 2021-10-08 22:20:14
言語 C++17
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 313 ms / 3,000 ms
コード長 986 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,103 ms
コンパイル使用メモリ 292,844 KB
実行使用メモリ 24,448 KB
最終ジャッジ日時 2026-06-23 08:31:17
合計ジャッジ時間 10,914 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 51
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint1000000007;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000000


int main(){
	
	long long n,m;
	cin>>n>>m;
	
	map<long long,set<long long>> mp;
	
	map<long long,long long> mp2;
	
	rep(i,m){
		long long a;
		scanf("%lld",&a);
		mp2[i+1] = a;
		mp[a].insert(i+1);
	}
	int q;
	cin>>q;
	rep(i,q){
		int t;
		long long x,y;
		scanf("%d %lld %lld",&t,&x,&y);
		
		if(t==1){
			if(mp2.count(x)){
				mp[mp2[x]].erase(x);
				if(mp[mp2[x]].size()==0)mp.erase(mp2[x]);
				mp2[x] += y;
				mp[mp2[x]].insert(x);
				
			}
			else{
				mp2[x] = y;
				mp[y].insert(x);
			}
		}
		if(t==2){
			mp[mp2[x]].erase(x);
			if(mp[mp2[x]].size()==0)mp.erase(mp2[x]);
			mp2[x] -= y;
			mp[mp2[x]].insert(x);
		}
		if(t==3){
			auto it = mp.end();
			it--;
			auto it2=  it->second.end();
			it2--;
			printf("%lld\n",(*it2));
		}
		
		
	}
	
	return 0;
}
0