# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1013714 | kebine | Martian DNA (BOI18_dna) | C++17 | 22 ms | 6748 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |