답안 #467390

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
467390 2021-08-22T21:57:00 Z Ozy Martian DNA (BOI18_dna) C++17
100 / 100
42 ms 5328 KB
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int i = (a); i <= (b); i++)
#define repa(i,a,b) for (int i = (a); i >= (b); i--)
#define lli long long int
#define debug(a) cout << #a << " = " << a << endl
#define debugsl(a) cout << #a << " = " << a << ", "

#define MAX 200000

lli n,r,k,a,b,ini,falt,res;
lli arr[MAX+2], requeridos[MAX+2];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n >> k >> r;
    rep(i,1,n) cin >> arr[i];

    rep(i,1,r) {
        cin >> a >> b;
        requeridos[a] = b;
        falt += b;
    }

    ini = 1;
    res = -1;

    rep(fin,1,n) {

        a = arr[fin];
        if(requeridos[a] > 0) falt--;
        requeridos[a]--;

        while (falt == 0) {

            a = fin-ini+1;
            if (res == -1 || a < res) res = a;

            a = arr[ini++];
            if (requeridos[a] >= 0) falt++;
            requeridos[a]++;
        }
    }

    if (res == -1) cout << "impossible";
    else cout << res;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 324 KB Output is correct
7 Correct 1 ms 320 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 0 ms 332 KB Output is correct
11 Correct 0 ms 320 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 2252 KB Output is correct
2 Correct 17 ms 2268 KB Output is correct
3 Correct 17 ms 2236 KB Output is correct
4 Correct 17 ms 2212 KB Output is correct
5 Correct 22 ms 3648 KB Output is correct
6 Correct 17 ms 2204 KB Output is correct
7 Correct 17 ms 2452 KB Output is correct
8 Correct 24 ms 4588 KB Output is correct
9 Correct 26 ms 2848 KB Output is correct
10 Correct 17 ms 2284 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 328 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 0 ms 332 KB Output is correct
21 Correct 0 ms 332 KB Output is correct
22 Correct 0 ms 332 KB Output is correct
23 Correct 0 ms 320 KB Output is correct
24 Correct 0 ms 204 KB Output is correct
25 Correct 0 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 35 ms 4164 KB Output is correct
2 Correct 32 ms 3876 KB Output is correct
3 Correct 26 ms 3596 KB Output is correct
4 Correct 16 ms 2188 KB Output is correct
5 Correct 39 ms 4804 KB Output is correct
6 Correct 42 ms 5328 KB Output is correct
7 Correct 21 ms 2892 KB Output is correct
8 Correct 25 ms 3144 KB Output is correct
9 Correct 16 ms 2244 KB Output is correct
10 Correct 17 ms 2264 KB Output is correct
11 Correct 19 ms 2224 KB Output is correct
12 Correct 17 ms 2204 KB Output is correct
13 Correct 22 ms 3624 KB Output is correct
14 Correct 16 ms 2252 KB Output is correct
15 Correct 17 ms 2340 KB Output is correct
16 Correct 24 ms 4676 KB Output is correct
17 Correct 24 ms 2804 KB Output is correct
18 Correct 16 ms 2196 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 352 KB Output is correct
24 Correct 1 ms 324 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 0 ms 332 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 0 ms 332 KB Output is correct
33 Correct 1 ms 332 KB Output is correct