답안 #497669

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
497669 2021-12-23T14:02:44 Z LittleCube Martian DNA (BOI18_dna) C++14
100 / 100
95 ms 4508 KB
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define F first
#define S second
using namespace std;

int N, K, R, arr[200005], acc[200005], lim[200005], remain, ans = 1e9;

signed main()
{
    cin >> N >> K >> R;
    remain = R;
    for (int i = 1; i <= N; i++)
        cin >> arr[i];
    for (int i = 1; i <= R; i++)
    {
        int B, Q;
        cin >> B >> Q;
        lim[B] = Q;
    }
    for (int l = 1, r = 1; l <= N; l++)
    {
        while(r <= N && remain > 0)
        {
            acc[arr[r]]++;
            if(acc[arr[r]] == lim[arr[r]])
                remain--;
            r++;
        }
        if(remain == 0)
            ans = min(ans, r - l);
        if(acc[arr[l]] == lim[arr[l]])
            remain++;
        acc[arr[l]]--;
    }
    if(ans > N)
        cout << "impossible\n";
    else
        cout << ans << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 304 KB Output is correct
2 Correct 1 ms 308 KB Output is correct
3 Correct 0 ms 308 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 1 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 2 ms 324 KB Output is correct
4 Correct 2 ms 328 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 308 KB Output is correct
7 Correct 1 ms 208 KB Output is correct
8 Correct 0 ms 208 KB Output is correct
9 Correct 1 ms 208 KB Output is correct
10 Correct 1 ms 208 KB Output is correct
11 Correct 0 ms 208 KB Output is correct
12 Correct 0 ms 208 KB Output is correct
13 Correct 0 ms 208 KB Output is correct
14 Correct 0 ms 208 KB Output is correct
15 Correct 0 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 1352 KB Output is correct
2 Correct 28 ms 1460 KB Output is correct
3 Correct 29 ms 1608 KB Output is correct
4 Correct 31 ms 1468 KB Output is correct
5 Correct 52 ms 2528 KB Output is correct
6 Correct 28 ms 1460 KB Output is correct
7 Correct 32 ms 1608 KB Output is correct
8 Correct 57 ms 3072 KB Output is correct
9 Correct 48 ms 2040 KB Output is correct
10 Correct 29 ms 1480 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 2 ms 336 KB Output is correct
14 Correct 1 ms 316 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 208 KB Output is correct
18 Correct 0 ms 208 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 0 ms 308 KB Output is correct
21 Correct 1 ms 208 KB Output is correct
22 Correct 0 ms 208 KB Output is correct
23 Correct 0 ms 208 KB Output is correct
24 Correct 1 ms 208 KB Output is correct
25 Correct 1 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 84 ms 3528 KB Output is correct
2 Correct 76 ms 3124 KB Output is correct
3 Correct 77 ms 2772 KB Output is correct
4 Correct 33 ms 1588 KB Output is correct
5 Correct 93 ms 4020 KB Output is correct
6 Correct 95 ms 4508 KB Output is correct
7 Correct 50 ms 2084 KB Output is correct
8 Correct 56 ms 2356 KB Output is correct
9 Correct 28 ms 1440 KB Output is correct
10 Correct 28 ms 1460 KB Output is correct
11 Correct 30 ms 1460 KB Output is correct
12 Correct 29 ms 1460 KB Output is correct
13 Correct 51 ms 2476 KB Output is correct
14 Correct 27 ms 1484 KB Output is correct
15 Correct 34 ms 1632 KB Output is correct
16 Correct 61 ms 3104 KB Output is correct
17 Correct 47 ms 1992 KB Output is correct
18 Correct 27 ms 1456 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 2 ms 336 KB Output is correct
23 Correct 2 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 0 ms 208 KB Output is correct
26 Correct 0 ms 208 KB Output is correct
27 Correct 0 ms 304 KB Output is correct
28 Correct 0 ms 208 KB Output is correct
29 Correct 0 ms 304 KB Output is correct
30 Correct 0 ms 208 KB Output is correct
31 Correct 0 ms 208 KB Output is correct
32 Correct 0 ms 208 KB Output is correct
33 Correct 0 ms 208 KB Output is correct