# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1013783 |
2024-07-04T05:50:13 Z |
vjudge1 |
Martian DNA (BOI18_dna) |
C++17 |
|
71 ms |
4948 KB |
#include "bits/stdc++.h"
#define F first
#define S second
#define ll long long
#define pii pair<ll,ll>
const ll mxN = 5e5 + 5;
ll mod = 1e9 + 7;
using namespace std;
int fr[mxN];
int req[mxN];
int a[mxN];
int main(){
int n,k,rq;
cin >>n>>k>>rq;
for(int i = 1;i <= n;i++) cin >>a[i];
for(int i = 1;i <= rq;i++){
int x;
cin >>x;
cin >>req[x];
}
int ans = 1e9;
int l = 1,r = 1;
int tc = 0;
while(l <= r && r <= n){
fr[a[r]]++;
if(fr[a[r]] == req[a[r]]) tc++;
if(tc == rq) ans = min(ans,r - l + 1);
while(tc == rq && l < r){
ans = min(ans,r - l + 1);
fr[a[l]]--;
if(fr[a[l]] == req[a[l]] - 1) tc--;
l++;
}
r++;
}
if(ans != 1e9) cout<<ans;
else cout<<"impossible";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2396 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
0 ms |
2396 KB |
Output is correct |
6 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 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 |
2396 KB |
Output is correct |
6 |
Correct |
0 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
0 ms |
2396 KB |
Output is correct |
9 |
Correct |
0 ms |
2396 KB |
Output is correct |
10 |
Correct |
0 ms |
2396 KB |
Output is correct |
11 |
Correct |
0 ms |
2396 KB |
Output is correct |
12 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
2668 KB |
Output is correct |
2 |
Correct |
18 ms |
2652 KB |
Output is correct |
3 |
Correct |
22 ms |
2652 KB |
Output is correct |
4 |
Correct |
16 ms |
2672 KB |
Output is correct |
5 |
Correct |
28 ms |
2908 KB |
Output is correct |
6 |
Correct |
16 ms |
2676 KB |
Output is correct |
7 |
Correct |
17 ms |
2648 KB |
Output is correct |
8 |
Correct |
33 ms |
3432 KB |
Output is correct |
9 |
Correct |
26 ms |
2652 KB |
Output is correct |
10 |
Correct |
14 ms |
2648 KB |
Output is correct |
11 |
Correct |
1 ms |
2396 KB |
Output is correct |
12 |
Correct |
1 ms |
2396 KB |
Output is correct |
13 |
Correct |
1 ms |
2396 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
15 |
Correct |
1 ms |
2492 KB |
Output is correct |
16 |
Correct |
1 ms |
2396 KB |
Output is correct |
17 |
Correct |
0 ms |
2396 KB |
Output is correct |
18 |
Correct |
0 ms |
2396 KB |
Output is correct |
19 |
Correct |
1 ms |
2396 KB |
Output is correct |
20 |
Correct |
0 ms |
2396 KB |
Output is correct |
21 |
Correct |
0 ms |
2396 KB |
Output is correct |
22 |
Incorrect |
0 ms |
2396 KB |
Output isn't correct |
23 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
62 ms |
2940 KB |
Output is correct |
2 |
Correct |
44 ms |
2648 KB |
Output is correct |
3 |
Correct |
31 ms |
2652 KB |
Output is correct |
4 |
Correct |
16 ms |
2648 KB |
Output is correct |
5 |
Correct |
56 ms |
4716 KB |
Output is correct |
6 |
Correct |
71 ms |
3664 KB |
Output is correct |
7 |
Correct |
28 ms |
2648 KB |
Output is correct |
8 |
Correct |
33 ms |
2652 KB |
Output is correct |
9 |
Correct |
15 ms |
2672 KB |
Output is correct |
10 |
Correct |
17 ms |
2652 KB |
Output is correct |
11 |
Correct |
19 ms |
2652 KB |
Output is correct |
12 |
Correct |
18 ms |
2672 KB |
Output is correct |
13 |
Correct |
31 ms |
4716 KB |
Output is correct |
14 |
Correct |
17 ms |
2652 KB |
Output is correct |
15 |
Correct |
18 ms |
2648 KB |
Output is correct |
16 |
Correct |
29 ms |
4948 KB |
Output is correct |
17 |
Correct |
24 ms |
2668 KB |
Output is correct |
18 |
Correct |
15 ms |
2652 KB |
Output is correct |
19 |
Correct |
1 ms |
2396 KB |
Output is correct |
20 |
Correct |
1 ms |
2396 KB |
Output is correct |
21 |
Correct |
1 ms |
2396 KB |
Output is correct |
22 |
Correct |
1 ms |
2396 KB |
Output is correct |
23 |
Correct |
1 ms |
2396 KB |
Output is correct |
24 |
Correct |
1 ms |
2396 KB |
Output is correct |
25 |
Correct |
0 ms |
2396 KB |
Output is correct |
26 |
Correct |
1 ms |
2396 KB |
Output is correct |
27 |
Correct |
1 ms |
2396 KB |
Output is correct |
28 |
Correct |
0 ms |
2396 KB |
Output is correct |
29 |
Correct |
0 ms |
2396 KB |
Output is correct |
30 |
Incorrect |
0 ms |
2396 KB |
Output isn't correct |
31 |
Halted |
0 ms |
0 KB |
- |