結果

問題 No.1705 Mode of long array
ユーザー 沙耶花沙耶花
提出日時 2021-10-08 22:20:14
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 497 ms / 3,000 ms
コード長 986 bytes
コンパイル時間 4,859 ms
コンパイル使用メモリ 279,448 KB
実行使用メモリ 24,132 KB
最終ジャッジ日時 2023-09-30 10:44:26
合計ジャッジ時間 16,481 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 3 ms
4,380 KB
testcase_04 AC 3 ms
4,376 KB
testcase_05 AC 3 ms
4,376 KB
testcase_06 AC 7 ms
4,380 KB
testcase_07 AC 8 ms
4,376 KB
testcase_08 AC 8 ms
4,384 KB
testcase_09 AC 7 ms
4,380 KB
testcase_10 AC 6 ms
4,376 KB
testcase_11 AC 8 ms
4,380 KB
testcase_12 AC 7 ms
4,376 KB
testcase_13 AC 287 ms
19,684 KB
testcase_14 AC 168 ms
12,912 KB
testcase_15 AC 110 ms
5,492 KB
testcase_16 AC 148 ms
6,640 KB
testcase_17 AC 97 ms
5,824 KB
testcase_18 AC 82 ms
6,056 KB
testcase_19 AC 199 ms
10,080 KB
testcase_20 AC 113 ms
8,136 KB
testcase_21 AC 213 ms
17,576 KB
testcase_22 AC 335 ms
22,364 KB
testcase_23 AC 74 ms
4,376 KB
testcase_24 AC 74 ms
4,380 KB
testcase_25 AC 74 ms
4,380 KB
testcase_26 AC 73 ms
4,376 KB
testcase_27 AC 74 ms
4,380 KB
testcase_28 AC 73 ms
4,376 KB
testcase_29 AC 73 ms
4,376 KB
testcase_30 AC 73 ms
4,380 KB
testcase_31 AC 74 ms
4,380 KB
testcase_32 AC 74 ms
4,376 KB
testcase_33 AC 493 ms
24,124 KB
testcase_34 AC 483 ms
24,132 KB
testcase_35 AC 497 ms
23,848 KB
testcase_36 AC 487 ms
23,896 KB
testcase_37 AC 486 ms
23,908 KB
testcase_38 AC 479 ms
23,904 KB
testcase_39 AC 477 ms
24,116 KB
testcase_40 AC 474 ms
23,908 KB
testcase_41 AC 480 ms
23,848 KB
testcase_42 AC 489 ms
23,856 KB
testcase_43 AC 101 ms
14,476 KB
testcase_44 AC 100 ms
14,620 KB
testcase_45 AC 100 ms
14,604 KB
testcase_46 AC 102 ms
14,528 KB
testcase_47 AC 103 ms
14,592 KB
testcase_48 AC 101 ms
14,588 KB
testcase_49 AC 226 ms
14,560 KB
testcase_50 AC 228 ms
14,576 KB
testcase_51 AC 224 ms
14,524 KB
testcase_52 AC 225 ms
14,528 KB
testcase_53 AC 225 ms
14,532 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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