結果
問題 |
No.2930 Larger Mex
|
ユーザー |
|
提出日時 | 2024-12-08 23:42:42 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,435 bytes |
コンパイル時間 | 1,209 ms |
コンパイル使用メモリ | 122,880 KB |
最終ジャッジ日時 | 2025-02-26 11:38:32 |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 5 TLE * 1 -- * 44 |
ソースコード
#include<iostream> #include<string> #include<queue> #include<vector> #include<cassert> #include<random> #include<set> #include<map> #include<cassert> #include<unordered_map> #include<bitset> #include<numeric> #include<algorithm> using namespace std; using ll = long long; const int inf=1<<30; const ll INF=1LL<<62; typedef pair<int,ll> P; typedef pair<int,P> PP; const ll MOD=998244353; const int dy[]={0,1,0,-1}; const int dx[]={1,0,-1,0}; int main(){ int N,M; cin>>N>>M; vector<int> A(N); for(int i=0;i<N;i++){ cin>>A[i]; } vector<ll> ans(N+1,0); const int MAXA=2*100000; vector<int> cnt_appear(MAXA+1,0); for(int k=1;k<=N;k++){ set<int> st; cnt_appear.assign(MAXA+1,0); for(int t=0;t<=k;t++){ st.insert(t); } for(int t=0;t<k;t++){ cnt_appear[A[t]]++; if(st.count(A[t])){ st.erase(A[t]); } } if(*st.begin()>=M){ ans[k]++; } for(int t=k;t<N;t++){ cnt_appear[A[t-k]]--; if(cnt_appear[A[t-k]]==0){ st.insert(A[t-k]); } cnt_appear[A[t]]++; if(st.count(A[t])){ st.erase(A[t]); } if(*st.begin()>=M){ ans[k]++; } } } for(int k=1;k<=N;k++){ cout<<ans[k]<<endl; } }