제출 #1123828

#제출 시각아이디문제언어결과실행 시간메모리
1123828emyz Martian DNA (BOI18_dna)C++20
0 / 100
65 ms2120 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n, k, r; cin>>n>>k>>r; int l[n], sum[k]={0}, min=n+1, need[n]={0}, complete=0; bool full[k] = {false}; for (int i=0; i<n; ++i) { cin>>l[i]; need[i]=1; } for (int i=0; i<r; ++i) { int a,b; cin>>a>>b; need[a]=b; } int left=0, right=0; int change=1; for (; right<n;) { if (change==0) { sum[l[left-1]]--; if (need[l[left-1]]>sum[l[left-1]]) { complete--; } } else if (change==1) { sum[l[right]]++; if (need[l[right]]==sum[l[right]]) { complete++; } } if (complete==k) { change=0; left++; if (right-left+2<min) { min=right-left+2; } } else { right++; change=1; } } if (min>=n) { cout<<"impossible"; } else { cout<<min<<endl; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...