#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
int n,k,r,m=LLONG_MAX;
cin>>n>>k>>r;
int a[n];
int d[k+1];
int re[r][2];
for(int i=0;i<n;i++){
cin>>a[i];
}
for(int i=0;i<=k;i++){
d[i]=0;
}
for(int i=0;i<r;i++){
int b,q;
cin>>b>>q;
re[i][0]=b;
re[i][1]=q;
}
int l=0,ri=0;
d[a[0]]==1;
while(l<n&&ri<n){
//check
bool allin=1;
for(int i=0;i<r;i++){
if(d[re[i][0]]<re[i][1]){
allin=0;break;
}
}
if(allin==1){
m=min(m,ri-l);
l++;
d[a[l]]--;
for(int i=l;i<=ri;i++){
cout<<a[i] <<" ";
}
} else{
ri++;
d[a[min(ri,n-1)]]++;
}
if(l==ri){
cout<<1;
return 0;
}
}
if(m==LLONG_MAX){
cout<<"impossible";
} else{
cout<< m;
}
}
Compilation message
dna.cpp: In function 'int main()':
dna.cpp:26:12: warning: statement has no effect [-Wunused-value]
26 | d[a[0]]==1;
| ~~~~~~~^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
145 ms |
6220 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2029 ms |
85532 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2057 ms |
203948 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |