Submission #957413

# Submission time Handle Problem Language Result Execution time Memory
957413 2024-04-03T16:26:49 Z vjudge1 Martian DNA (BOI18_dna) C++17
100 / 100
343 ms 28308 KB
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>

const ll N = 200069;
const ll mod = 1e9 + 7;

int tc;
ll n, k, r;

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll i, j;
    
    cin >> n >> k >> r;
    
    ll a[n+5];
    for(i = 1; i <= n; i++)
    {
        cin >> a[i];
    }

    map<ll, ll> need, cur;
    for(i = 1; i <= r; i++)
    {
        ll x, y;
        cin >> x >> y;
        need[x] = y;
    }
    
    ll ans = 1e18, sz = max(0ll, k - r);
    j = 1;
    for(i = 1; i <= n; i++)
    {
        ++cur[a[i]];
        if(cur[a[i]] == need[a[i]])
        {
            ++sz;
        }
        while(j <= n and sz == k)
        {
            ans = min(ans, i - j + 1);
            --cur[a[j]];
            if(cur[a[j]] == need[a[j]] - 1) --sz;
            ++j;
        }
    }

    if(ans == 1e18)
    {
        cout << "impossible\n";
    }
    else cout << ans << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 600 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 2 ms 856 KB Output is correct
4 Correct 3 ms 860 KB Output is correct
5 Correct 2 ms 604 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 1880 KB Output is correct
2 Correct 11 ms 1884 KB Output is correct
3 Correct 17 ms 2016 KB Output is correct
4 Correct 19 ms 2012 KB Output is correct
5 Correct 165 ms 12960 KB Output is correct
6 Correct 14 ms 2396 KB Output is correct
7 Correct 23 ms 2396 KB Output is correct
8 Correct 256 ms 28308 KB Output is correct
9 Correct 91 ms 3924 KB Output is correct
10 Correct 18 ms 2396 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 3 ms 600 KB Output is correct
14 Correct 3 ms 860 KB Output is correct
15 Correct 2 ms 604 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 456 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 206 ms 13652 KB Output is correct
2 Correct 154 ms 11092 KB Output is correct
3 Correct 152 ms 10812 KB Output is correct
4 Correct 11 ms 2396 KB Output is correct
5 Correct 224 ms 16676 KB Output is correct
6 Correct 343 ms 26452 KB Output is correct
7 Correct 75 ms 3932 KB Output is correct
8 Correct 116 ms 5460 KB Output is correct
9 Correct 14 ms 2392 KB Output is correct
10 Correct 13 ms 2392 KB Output is correct
11 Correct 16 ms 2392 KB Output is correct
12 Correct 15 ms 2396 KB Output is correct
13 Correct 158 ms 13140 KB Output is correct
14 Correct 14 ms 2396 KB Output is correct
15 Correct 20 ms 2396 KB Output is correct
16 Correct 271 ms 28120 KB Output is correct
17 Correct 94 ms 3956 KB Output is correct
18 Correct 17 ms 2396 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 2 ms 600 KB Output is correct
22 Correct 3 ms 860 KB Output is correct
23 Correct 2 ms 604 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct