提出 #76059775


ソースコード 拡げる

#include<bits/stdc++.h>
using namespace std;
int n,q,op,x,k,a[600005],b[600005];
void add(int i,int x){
	if(i==0) b[0]+=x;
	else for(;i<=600000;i+=i&(-i)) b[i]+=x;
}
int sum(int i){
	i+=k;
	if(i<0) return 0;
	int ans=b[0];
	for(;i;i-=i&(-i)) ans+=b[i];
	return ans;
}  
int main(){
	cin>>n>>q,b[0]=n;
	while(q--){
		cin>>op>>x;
		if(op==1){
			add(a[x],-1),a[x]++,add(a[x],1);
			if(sum(0)-sum(-1)==0) k++;
		}
		else cout<<n-sum(x-1)<<endl;
	}
}

提出情報

提出日時
問題 C - Drop Blocks
ユーザ Rya_
言語 C++23 (GCC 15.2.0)
得点 300
コード長 470 Byte
結果 AC
実行時間 184 ms
メモリ 4844 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 300 / 300
結果
AC × 1
AC × 50
セット名 テストケース
Sample example_00.txt
All example_00.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, hand_07.txt, hand_08.txt, hand_09.txt, hand_10.txt, hand_11.txt, hand_12.txt, hand_13.txt, hand_14.txt, hand_15.txt, hand_16.txt, hand_17.txt, hand_18.txt, hand_19.txt, hand_20.txt, hand_21.txt, hand_22.txt, hand_23.txt, hand_24.txt, hand_25.txt, hand_26.txt, hand_27.txt, hand_28.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt
ケース名 結果 実行時間 メモリ
example_00.txt AC 1 ms 3588 KiB
hand_00.txt AC 76 ms 4740 KiB
hand_01.txt AC 76 ms 4664 KiB
hand_02.txt AC 180 ms 3504 KiB
hand_03.txt AC 153 ms 3548 KiB
hand_04.txt AC 118 ms 4016 KiB
hand_05.txt AC 118 ms 3548 KiB
hand_06.txt AC 115 ms 3656 KiB
hand_07.txt AC 58 ms 4704 KiB
hand_08.txt AC 154 ms 3504 KiB
hand_09.txt AC 110 ms 4176 KiB
hand_10.txt AC 112 ms 3808 KiB
hand_11.txt AC 71 ms 4732 KiB
hand_12.txt AC 72 ms 4544 KiB
hand_13.txt AC 173 ms 3464 KiB
hand_14.txt AC 130 ms 4028 KiB
hand_15.txt AC 128 ms 3916 KiB
hand_16.txt AC 1 ms 3420 KiB
hand_17.txt AC 184 ms 3568 KiB
hand_18.txt AC 55 ms 4680 KiB
hand_19.txt AC 55 ms 4544 KiB
hand_20.txt AC 58 ms 4808 KiB
hand_21.txt AC 121 ms 4740 KiB
hand_22.txt AC 79 ms 4844 KiB
hand_23.txt AC 156 ms 4196 KiB
hand_24.txt AC 153 ms 4680 KiB
hand_25.txt AC 1 ms 3400 KiB
hand_26.txt AC 1 ms 3548 KiB
hand_27.txt AC 14 ms 4800 KiB
hand_28.txt AC 99 ms 3936 KiB
random_00.txt AC 113 ms 4136 KiB
random_01.txt AC 124 ms 3480 KiB
random_02.txt AC 122 ms 3524 KiB
random_03.txt AC 137 ms 3504 KiB
random_04.txt AC 152 ms 3780 KiB
random_05.txt AC 128 ms 3752 KiB
random_06.txt AC 88 ms 3552 KiB
random_07.txt AC 152 ms 3552 KiB
random_08.txt AC 103 ms 3508 KiB
random_09.txt AC 110 ms 3524 KiB
random_10.txt AC 135 ms 3588 KiB
random_11.txt AC 93 ms 3556 KiB
random_12.txt AC 160 ms 3588 KiB
random_13.txt AC 125 ms 3504 KiB
random_14.txt AC 113 ms 3700 KiB
random_15.txt AC 83 ms 4320 KiB
random_16.txt AC 143 ms 3524 KiB
random_17.txt AC 94 ms 4264 KiB
random_18.txt AC 122 ms 3548 KiB
random_19.txt AC 113 ms 3588 KiB