結果

問題 No.833 かっこいい電車
ユーザー 👑 kmjpkmjp
提出日時 2019-05-24 22:19:15
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 108 ms / 2,000 ms
コード長 1,378 bytes
コンパイル時間 1,534 ms
コンパイル使用メモリ 172,904 KB
実行使用メモリ 12,972 KB
最終ジャッジ日時 2023-09-14 20:52:46
合計ジャッジ時間 4,612 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 102 ms
10,236 KB
testcase_01 AC 2 ms
7,488 KB
testcase_02 AC 3 ms
7,516 KB
testcase_03 AC 3 ms
7,744 KB
testcase_04 AC 3 ms
7,520 KB
testcase_05 AC 2 ms
7,540 KB
testcase_06 AC 3 ms
7,540 KB
testcase_07 AC 2 ms
7,524 KB
testcase_08 AC 2 ms
7,732 KB
testcase_09 AC 2 ms
7,576 KB
testcase_10 AC 80 ms
10,504 KB
testcase_11 AC 108 ms
11,912 KB
testcase_12 AC 34 ms
9,328 KB
testcase_13 AC 24 ms
8,336 KB
testcase_14 AC 88 ms
12,008 KB
testcase_15 AC 43 ms
10,092 KB
testcase_16 AC 35 ms
10,980 KB
testcase_17 AC 31 ms
7,824 KB
testcase_18 AC 100 ms
10,736 KB
testcase_19 AC 34 ms
10,560 KB
testcase_20 AC 10 ms
8,540 KB
testcase_21 AC 80 ms
8,988 KB
testcase_22 AC 58 ms
12,600 KB
testcase_23 AC 39 ms
10,964 KB
testcase_24 AC 57 ms
12,136 KB
testcase_25 AC 91 ms
10,148 KB
testcase_26 AC 41 ms
11,084 KB
testcase_27 AC 66 ms
10,452 KB
testcase_28 AC 47 ms
8,920 KB
testcase_29 AC 57 ms
9,796 KB
testcase_30 AC 61 ms
12,972 KB
testcase_31 AC 101 ms
10,240 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

//さらに短縮
template<class V, int ME> class BIT {
public:
	V bit[1<<ME];
	V operator()(int e) {if(e<0) return 0;V s=0;e++;while(e) s+=bit[e-1],e-=e&-e; return s;}
	void add(int e,V v) { e++; while(e<=1<<ME) bit[e-1]+=v,e+=e&-e;}
};
BIT<ll,20> bt;

set<int> S;
int N,Q;


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>Q;
	for(i=1;i<=N;i++) {
		cin>>x;
		bt.add(i,x);
		S.insert(i);
	}
	S.insert(0);
	S.insert(N+1);
	while(Q--) {
		cin>>i>>x;
		if(i==1) S.erase(x+1);
		if(i==2) S.insert(x+1);
		if(i==3) bt.add(x,1);
		if(i==4) {
			auto it=S.lower_bound(x);
			if(*it==x) {
				it++;
				y=*it;
			}
			else {
				y=*it;
				it--;
				x=*it;
			}
			cout<<(bt(y-1)-bt(x-1))<<endl;
		}
	}
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0