提出 #76047348


ソースコード 拡げる

#include<bits/stdc++.h>
using namespace std;

#define int long long 

const int N=6e5+5;

bool st;
int n,q,a[N];
int cnt[N],del;
int lowbit(int x) {return x&(-x);}
inline void add(int pos,int x) {
	for(int i=pos;i<=6e5;i+=lowbit(i)) a[i]+=x;
}inline int get_sum(int pos) {
	int res=0;
	for(int i=pos;i;i-=lowbit(i)) res+=a[i];
	return res;
}
bool ed;

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	cerr<<(double)(&st-&ed)/1024/1024<<'\n';
	cin>>n>>q;
	add(1,n);
	for(int i=1;i<=q;i++) {
		int op,x;
		cin>>op>>x;
		if(op==1) {
			add(cnt[x]+1,-1);
			add(cnt[x]+2,1);
			if(!get_sum(del+1)) del++;
			cnt[x]++;
		}else {
			cout<<n-get_sum(x+del)<<'\n';
		}
	}
	return 0;
}

提出情報

提出日時
問題 C - Drop Blocks
ユーザ wallacewan
言語 C++23 (GCC 15.2.0)
得点 300
コード長 738 Byte
結果 AC
実行時間 30 ms
メモリ 6408 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 3856 KiB
hand_00.txt AC 30 ms 6184 KiB
hand_01.txt AC 29 ms 6272 KiB
hand_02.txt AC 26 ms 4104 KiB
hand_03.txt AC 20 ms 3836 KiB
hand_04.txt AC 24 ms 5004 KiB
hand_05.txt AC 24 ms 3944 KiB
hand_06.txt AC 20 ms 3880 KiB
hand_07.txt AC 19 ms 6128 KiB
hand_08.txt AC 20 ms 3936 KiB
hand_09.txt AC 20 ms 4980 KiB
hand_10.txt AC 20 ms 4368 KiB
hand_11.txt AC 19 ms 6408 KiB
hand_12.txt AC 19 ms 6208 KiB
hand_13.txt AC 23 ms 3928 KiB
hand_14.txt AC 25 ms 5080 KiB
hand_15.txt AC 25 ms 4416 KiB
hand_16.txt AC 1 ms 3904 KiB
hand_17.txt AC 22 ms 3904 KiB
hand_18.txt AC 18 ms 6240 KiB
hand_19.txt AC 18 ms 6240 KiB
hand_20.txt AC 19 ms 6272 KiB
hand_21.txt AC 27 ms 6204 KiB
hand_22.txt AC 30 ms 6160 KiB
hand_23.txt AC 21 ms 4776 KiB
hand_24.txt AC 23 ms 6272 KiB
hand_25.txt AC 1 ms 3952 KiB
hand_26.txt AC 1 ms 3932 KiB
hand_27.txt AC 5 ms 6256 KiB
hand_28.txt AC 22 ms 4620 KiB
random_00.txt AC 25 ms 5120 KiB
random_01.txt AC 22 ms 3852 KiB
random_02.txt AC 25 ms 3952 KiB
random_03.txt AC 25 ms 4096 KiB
random_04.txt AC 26 ms 4592 KiB
random_05.txt AC 21 ms 4744 KiB
random_06.txt AC 25 ms 3928 KiB
random_07.txt AC 27 ms 3972 KiB
random_08.txt AC 24 ms 4032 KiB
random_09.txt AC 25 ms 3956 KiB
random_10.txt AC 25 ms 3956 KiB
random_11.txt AC 25 ms 3880 KiB
random_12.txt AC 26 ms 3852 KiB
random_13.txt AC 25 ms 3928 KiB
random_14.txt AC 27 ms 4008 KiB
random_15.txt AC 20 ms 5696 KiB
random_16.txt AC 23 ms 3936 KiB
random_17.txt AC 21 ms 5388 KiB
random_18.txt AC 28 ms 4088 KiB
random_19.txt AC 25 ms 4096 KiB