# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1013789 |
2024-07-04T05:53:01 Z |
vjudge1 |
Martian DNA (BOI18_dna) |
C++17 |
|
154 ms |
4956 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 |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Incorrect |
0 ms |
2476 KB |
Output isn't correct |
7 |
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 |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
0 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 |
1 ms |
2392 KB |
Output is correct |
11 |
Correct |
0 ms |
2396 KB |
Output is correct |
12 |
Incorrect |
0 ms |
2396 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
2652 KB |
Output is correct |
2 |
Correct |
15 ms |
2576 KB |
Output is correct |
3 |
Correct |
17 ms |
2648 KB |
Output is correct |
4 |
Correct |
20 ms |
2648 KB |
Output is correct |
5 |
Correct |
29 ms |
4452 KB |
Output is correct |
6 |
Correct |
16 ms |
2648 KB |
Output is correct |
7 |
Correct |
21 ms |
2672 KB |
Output is correct |
8 |
Correct |
29 ms |
4948 KB |
Output is correct |
9 |
Correct |
22 ms |
2652 KB |
Output is correct |
10 |
Correct |
16 ms |
2652 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 |
2492 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
15 |
Correct |
1 ms |
2392 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 |
0 ms |
2396 KB |
Output is correct |
20 |
Correct |
0 ms |
2396 KB |
Output is correct |
21 |
Correct |
1 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 |
154 ms |
4456 KB |
Output is correct |
2 |
Correct |
41 ms |
2660 KB |
Output is correct |
3 |
Correct |
35 ms |
2908 KB |
Output is correct |
4 |
Correct |
18 ms |
2672 KB |
Output is correct |
5 |
Correct |
62 ms |
3156 KB |
Output is correct |
6 |
Correct |
64 ms |
4956 KB |
Output is correct |
7 |
Correct |
28 ms |
2652 KB |
Output is correct |
8 |
Correct |
39 ms |
2660 KB |
Output is correct |
9 |
Correct |
17 ms |
2652 KB |
Output is correct |
10 |
Correct |
16 ms |
2648 KB |
Output is correct |
11 |
Correct |
17 ms |
2652 KB |
Output is correct |
12 |
Correct |
22 ms |
2652 KB |
Output is correct |
13 |
Correct |
30 ms |
2900 KB |
Output is correct |
14 |
Correct |
15 ms |
2668 KB |
Output is correct |
15 |
Correct |
19 ms |
2660 KB |
Output is correct |
16 |
Correct |
32 ms |
4948 KB |
Output is correct |
17 |
Correct |
26 ms |
2660 KB |
Output is correct |
18 |
Correct |
17 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 |
0 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 |
2448 KB |
Output isn't correct |
31 |
Halted |
0 ms |
0 KB |
- |