結果

問題 No.1705 Mode of long array
ユーザー Drice27149Drice27149
提出日時 2021-10-08 23:01:45
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 62 ms / 3,000 ms
コード長 811 bytes
コンパイル時間 459 ms
コンパイル使用メモリ 52,952 KB
実行使用メモリ 9,336 KB
最終ジャッジ日時 2023-09-30 12:19:08
合計ジャッジ時間 5,969 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 4 ms
4,380 KB
testcase_07 AC 4 ms
4,376 KB
testcase_08 AC 4 ms
4,380 KB
testcase_09 AC 4 ms
4,376 KB
testcase_10 AC 4 ms
4,380 KB
testcase_11 AC 4 ms
4,380 KB
testcase_12 AC 4 ms
4,380 KB
testcase_13 AC 42 ms
5,420 KB
testcase_14 AC 31 ms
5,232 KB
testcase_15 AC 28 ms
4,380 KB
testcase_16 AC 36 ms
4,864 KB
testcase_17 AC 25 ms
4,380 KB
testcase_18 AC 21 ms
4,376 KB
testcase_19 AC 39 ms
4,944 KB
testcase_20 AC 25 ms
4,380 KB
testcase_21 AC 34 ms
5,108 KB
testcase_22 AC 52 ms
8,052 KB
testcase_23 AC 33 ms
4,724 KB
testcase_24 AC 34 ms
4,724 KB
testcase_25 AC 34 ms
4,708 KB
testcase_26 AC 33 ms
4,716 KB
testcase_27 AC 34 ms
4,712 KB
testcase_28 AC 33 ms
4,796 KB
testcase_29 AC 33 ms
4,636 KB
testcase_30 AC 33 ms
4,712 KB
testcase_31 AC 34 ms
4,672 KB
testcase_32 AC 33 ms
4,708 KB
testcase_33 AC 61 ms
7,760 KB
testcase_34 AC 61 ms
8,032 KB
testcase_35 AC 62 ms
9,336 KB
testcase_36 AC 61 ms
7,804 KB
testcase_37 AC 61 ms
8,872 KB
testcase_38 AC 62 ms
8,348 KB
testcase_39 AC 60 ms
8,516 KB
testcase_40 AC 61 ms
8,020 KB
testcase_41 AC 62 ms
9,304 KB
testcase_42 AC 62 ms
9,280 KB
testcase_43 AC 49 ms
5,208 KB
testcase_44 AC 50 ms
5,172 KB
testcase_45 AC 49 ms
5,156 KB
testcase_46 AC 49 ms
5,184 KB
testcase_47 AC 49 ms
5,132 KB
testcase_48 AC 49 ms
5,208 KB
testcase_49 AC 62 ms
9,136 KB
testcase_50 AC 61 ms
8,020 KB
testcase_51 AC 61 ms
8,024 KB
testcase_52 AC 61 ms
8,404 KB
testcase_53 AC 62 ms
9,320 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <queue>
struct Element{
	int val;
	long long cnt;
	bool operator < (const Element& other)const{
		if(cnt!=other.cnt) return cnt < other.cnt;
		else return val < other.val;
	}
};
long long time[100005];

int main(){
	long long m;
	int n;
	scanf("%lld%d",&m,&n);
	std::priority_queue<Element> Q;
	for(int i = 1; i <= n; i++){
		long long cnt;
		scanf("%lld",&cnt);
		time[i] = cnt;
		Q.push(Element{i,cnt});
	}
	int q;
	scanf("%d",&q);
	while(q--){
		int op;
		long long x,y;
		scanf("%d%lld%lld",&op,&x,&y);
		if(op == 1){
			time[x] += y;
			Q.push(Element{(int)x,time[x]});
		}
		else if(op == 2){
			time[x] -= y;
			Q.push(Element{(int)x,time[x]});
		}
		else{
			while(Q.size()!=0 && Q.top().cnt!=time[Q.top().val]) Q.pop();
			printf("%d\n",Q.top().val);
		}
	}
	
	
	return 0;
}
0