Submission #1013798

# Submission time Handle Problem Language Result Execution time Memory
1013798 2024-07-04T06:04:42 Z vjudge1 Martian DNA (BOI18_dna) C++17
100 / 100
60 ms 4968 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 2396 KB Output is correct
2 Correct 0 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 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
# 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 2392 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2392 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 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 0 ms 2396 KB Output is correct
13 Correct 0 ms 2396 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 2652 KB Output is correct
2 Correct 17 ms 2676 KB Output is correct
3 Correct 18 ms 2648 KB Output is correct
4 Correct 17 ms 2652 KB Output is correct
5 Correct 31 ms 4692 KB Output is correct
6 Correct 16 ms 2652 KB Output is correct
7 Correct 20 ms 2672 KB Output is correct
8 Correct 36 ms 4948 KB Output is correct
9 Correct 27 ms 2660 KB Output is correct
10 Correct 17 ms 2648 KB Output is correct
11 Correct 1 ms 2392 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 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 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 Correct 0 ms 2396 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 0 ms 2396 KB Output is correct
25 Correct 0 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 48 ms 4700 KB Output is correct
2 Correct 49 ms 2648 KB Output is correct
3 Correct 36 ms 2896 KB Output is correct
4 Correct 18 ms 2652 KB Output is correct
5 Correct 60 ms 4692 KB Output is correct
6 Correct 58 ms 4968 KB Output is correct
7 Correct 28 ms 2644 KB Output is correct
8 Correct 33 ms 2648 KB Output is correct
9 Correct 17 ms 2648 KB Output is correct
10 Correct 17 ms 2652 KB Output is correct
11 Correct 20 ms 2652 KB Output is correct
12 Correct 18 ms 2672 KB Output is correct
13 Correct 31 ms 4692 KB Output is correct
14 Correct 18 ms 2648 KB Output is correct
15 Correct 19 ms 2652 KB Output is correct
16 Correct 34 ms 4968 KB Output is correct
17 Correct 26 ms 2648 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 0 ms 2396 KB Output is correct
27 Correct 0 ms 2396 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
29 Correct 0 ms 2396 KB Output is correct
30 Correct 0 ms 2396 KB Output is correct
31 Correct 1 ms 2396 KB Output is correct
32 Correct 0 ms 2396 KB Output is correct
33 Correct 0 ms 2396 KB Output is correct