結果

問題 No.2930 Larger Mex
ユーザー 👑 kmjpkmjp
提出日時 2024-10-12 22:44:47
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,353 bytes
コンパイル時間 2,482 ms
コンパイル使用メモリ 209,180 KB
実行使用メモリ 42,600 KB
最終ジャッジ日時 2024-10-12 22:45:15
合計ジャッジ時間 26,374 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
22,360 KB
testcase_01 RE -
testcase_02 AC 22 ms
22,192 KB
testcase_03 AC 24 ms
22,548 KB
testcase_04 AC 25 ms
22,980 KB
testcase_05 AC 26 ms
22,468 KB
testcase_06 AC 27 ms
22,444 KB
testcase_07 AC 25 ms
22,368 KB
testcase_08 AC 412 ms
32,924 KB
testcase_09 AC 389 ms
32,448 KB
testcase_10 AC 408 ms
33,348 KB
testcase_11 AC 328 ms
31,340 KB
testcase_12 AC 521 ms
38,340 KB
testcase_13 AC 450 ms
34,600 KB
testcase_14 AC 599 ms
42,240 KB
testcase_15 AC 348 ms
32,128 KB
testcase_16 AC 333 ms
31,684 KB
testcase_17 AC 423 ms
33,280 KB
testcase_18 AC 329 ms
31,360 KB
testcase_19 AC 493 ms
34,816 KB
testcase_20 AC 442 ms
34,160 KB
testcase_21 AC 439 ms
33,792 KB
testcase_22 AC 558 ms
38,144 KB
testcase_23 AC 384 ms
33,124 KB
testcase_24 AC 385 ms
32,960 KB
testcase_25 AC 579 ms
41,088 KB
testcase_26 AC 387 ms
37,704 KB
testcase_27 AC 310 ms
32,892 KB
testcase_28 AC 354 ms
35,312 KB
testcase_29 AC 341 ms
34,640 KB
testcase_30 AC 313 ms
32,620 KB
testcase_31 AC 258 ms
31,972 KB
testcase_32 AC 334 ms
36,264 KB
testcase_33 AC 330 ms
33,672 KB
testcase_34 AC 430 ms
33,984 KB
testcase_35 AC 302 ms
31,692 KB
testcase_36 AC 349 ms
32,712 KB
testcase_37 AC 494 ms
36,028 KB
testcase_38 AC 374 ms
36,248 KB
testcase_39 AC 320 ms
33,872 KB
testcase_40 AC 337 ms
34,116 KB
testcase_41 AC 325 ms
33,024 KB
testcase_42 AC 345 ms
33,220 KB
testcase_43 AC 313 ms
32,328 KB
testcase_44 AC 381 ms
34,940 KB
testcase_45 AC 337 ms
34,692 KB
testcase_46 RE -
testcase_47 RE -
testcase_48 RE -
testcase_49 RE -
testcase_50 AC 350 ms
33,268 KB
testcase_51 AC 468 ms
37,924 KB
testcase_52 AC 620 ms
42,600 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#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 FORR2(x,y,arr) for(auto& [x,y]:arr)
#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 T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;}
//-------------------------------------------------------

int N,M;
int A[202020];
set<int> nex[202021];

int ret[202020];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	FOR(i,N) {
		cin>>A[i];
		nex[A[i]].insert(i);
	}
	FOR(i,202020) nex[i].insert(N+i);
	set<int> cand;
	FOR(i,M) cand.insert(*nex[i].begin());
	FOR(i,N) {
		x=*cand.rbegin();
		if(x<N) {
			ret[x-i+1]++;
			ret[N-i+1]--;
		}
		if(A[i]<M) {
			cand.erase(*nex[A[i]].begin());
			nex[A[i]].erase(nex[A[i]].begin());
			cand.insert(*nex[A[i]].begin());
		}
	}
	
	for(i=1;i<=N;i++) {
		ret[i]+=ret[i-1];
		cout<<ret[i]<<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