Submission #1013714

# Submission time Handle Problem Language Result Execution time Memory
1013714 2024-07-04T02:48:29 Z kebine Martian DNA (BOI18_dna) C++17
0 / 100
22 ms 6748 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define int long long
// Whatever happens... God had made a plan for you.♡
int con[2000001];
int countd[200001];
signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, k, r;
    int ans = INT_MAX;
    int arr[200001];
    cin >> n >> k >> r;
    for (int i = 1; i <= n; i++)
    {
        cin >> arr[i];
    }
    int ind, cnt;
    for (int i = 0; i < r; i++)
    {
        cin >> ind >> cnt;
        con[ind] = 1;
        countd[ind] += cnt;
    }
    int miau = r;
    bool temp = 1;
    int start = 1, stop = 1;
    while (stop <= n)
    {
        if (miau != 0)
        {
            if (con[arr[stop]])
            {
                if (countd[arr[stop]] == 1)
                {
                    miau--;
                }
                countd[arr[stop]]--;
            }
            stop++;
        }
        else
        {
            ans = min(ans, stop - 1 - start + 1);
            // cout << stop << " " << start << endl;
            if (con[arr[start]])
            {
                countd[arr[start]]++;
            }
            if (countd[arr[start]] > 0)
                miau++;
            start++;
        }
    }
    if (ans == INT_MAX)
        cout << "impossible" << endl;
    else
        cout << ans << endl;
}

Compilation message

dna.cpp: In function 'int main()':
dna.cpp:30:10: warning: unused variable 'temp' [-Wunused-variable]
   30 |     bool temp = 1;
      |          ^~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1884 KB Output is correct
2 Correct 1 ms 2020 KB Output is correct
3 Incorrect 1 ms 1884 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1884 KB Output is correct
2 Correct 1 ms 1884 KB Output is correct
3 Correct 1 ms 1884 KB Output is correct
4 Correct 1 ms 1884 KB Output is correct
5 Correct 1 ms 1884 KB Output is correct
6 Correct 1 ms 1884 KB Output is correct
7 Correct 1 ms 2020 KB Output is correct
8 Correct 1 ms 1884 KB Output is correct
9 Incorrect 1 ms 1884 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 2396 KB Output is correct
2 Correct 12 ms 2396 KB Output is correct
3 Correct 9 ms 2396 KB Output is correct
4 Correct 8 ms 2396 KB Output is correct
5 Correct 12 ms 3164 KB Output is correct
6 Incorrect 8 ms 2396 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 20 ms 4956 KB Output is correct
2 Correct 17 ms 4568 KB Output is correct
3 Correct 14 ms 4188 KB Output is correct
4 Correct 8 ms 2392 KB Output is correct
5 Correct 20 ms 5716 KB Output is correct
6 Correct 22 ms 6748 KB Output is correct
7 Correct 11 ms 3036 KB Output is correct
8 Correct 19 ms 3416 KB Output is correct
9 Correct 12 ms 2396 KB Output is correct
10 Correct 8 ms 2388 KB Output is correct
11 Correct 13 ms 2392 KB Output is correct
12 Correct 8 ms 2396 KB Output is correct
13 Correct 10 ms 3160 KB Output is correct
14 Incorrect 8 ms 2396 KB Output isn't correct
15 Halted 0 ms 0 KB -