# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
934940 |
2024-02-28T08:12:11 Z |
ttamx |
Martian DNA (BOI18_dna) |
C++17 |
|
24 ms |
4908 KB |
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int n,k,r;
int a[N],mn[N],cnt[N];
int main(){
cin.tie(nullptr)->sync_with_stdio(false);
cin >> n >> k >> r;
for(int i=1;i<=n;i++)cin >> a[i];
for(int i=0;i<r;i++){
int x,y;
cin >> x >> y;
mn[x]=y;
}
int p=1;
for(int i=0;i<k;i++)while(cnt[i]<mn[i]&&p<=n)cnt[a[p++]]++;
if(p>n)cout << "impossible\n",exit(0);
int ans=p-1;
for(int i=1;i<n;i++){
cnt[a[i]]--;
while(cnt[a[i]]<mn[a[i]]&&p<=n)cnt[a[p++]]++;
if(p>n)break;
ans=min(ans,p-i-1);
}
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2532 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
2908 KB |
Output is correct |
2 |
Correct |
13 ms |
2908 KB |
Output is correct |
3 |
Correct |
10 ms |
3032 KB |
Output is correct |
4 |
Correct |
14 ms |
2912 KB |
Output is correct |
5 |
Correct |
12 ms |
3912 KB |
Output is correct |
6 |
Incorrect |
8 ms |
2908 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
21 ms |
4440 KB |
Output is correct |
2 |
Correct |
19 ms |
4184 KB |
Output is correct |
3 |
Correct |
16 ms |
3932 KB |
Output is correct |
4 |
Correct |
9 ms |
2908 KB |
Output is correct |
5 |
Correct |
21 ms |
4908 KB |
Output is correct |
6 |
Correct |
24 ms |
4804 KB |
Output is correct |
7 |
Correct |
13 ms |
3516 KB |
Output is correct |
8 |
Correct |
14 ms |
3652 KB |
Output is correct |
9 |
Correct |
9 ms |
2888 KB |
Output is correct |
10 |
Correct |
10 ms |
2908 KB |
Output is correct |
11 |
Correct |
10 ms |
2880 KB |
Output is correct |
12 |
Correct |
9 ms |
3160 KB |
Output is correct |
13 |
Correct |
12 ms |
3932 KB |
Output is correct |
14 |
Incorrect |
8 ms |
2908 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |