Submission #1013714

#TimeUsernameProblemLanguageResultExecution timeMemory
1013714kebine Martian DNA (BOI18_dna)C++17
0 / 100
22 ms6748 KiB
#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 (stderr)

dna.cpp: In function 'int main()':
dna.cpp:30:10: warning: unused variable 'temp' [-Wunused-variable]
   30 |     bool temp = 1;
      |          ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...