結果

問題 No.1705 Mode of long array
ユーザー kotatsugame
提出日時 2021-10-08 22:20:43
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 247 ms / 3,000 ms
コード長 614 bytes
コンパイル時間 1,074 ms
コンパイル使用メモリ 79,220 KB
実行使用メモリ 9,028 KB
最終ジャッジ日時 2024-07-23 04:51:36
合計ジャッジ時間 9,599 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 51
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    7 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<atcoder/segtree>
using namespace std;
using dat=pair<long,int>;
dat op(dat a,dat b){return a<b?b:a;}
dat e(){return make_pair(-1,-1);}
main()
{
	long N;
	int M;
	cin>>N>>M;
	vector<dat>init(M);
	for(int i=0;i<M;i++)
	{
		long a;cin>>a;
		init[i]=make_pair(a,i);
	}
	atcoder::segtree<dat,op,e>P(init);
	int Q;cin>>Q;
	for(;Q--;)
	{
		int t,x;
		long y;
		cin>>t>>x>>y;
		x--;
		if(t==1)
		{
			dat now=P.get(x);
			now.first+=y;
			P.set(x,now);
		}
		else if(t==2)
		{
			dat now=P.get(x);
			now.first-=y;
			P.set(x,now);
		}
		else
		{
			cout<<P.all_prod().second+1<<"\n";
		}
	}
}
0