# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1033064 | vannnnnnnn | Martian DNA (BOI18_dna) | C++14 | 2032 ms | 3932 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;
int note[200005], lst[200005], mp[200005], a[200005];
int main()
{
int n, k, r, ans=1e9;
scanf("%d %d %d", &n, &k, &r);
for(int i=1; i<=n; i++)
{
scanf("%d", &a[i]);
}
for(int i=1; i<=r; i++)
{
int c, d;
scanf("%d %d", &c, &d);
note[c]=d;
lst[i]=c;
}
int start=1;
for(int i=1; i<=n; i++)
{
mp[a[i]]++;
int find=1;
for(int j=1; j<=r; j++)
{
if(mp[lst[j]]<note[lst[j]])
{
find=0;
break;
}
}
if(find==1)
{
while(start<i)
{
if(mp[a[start]]-1>=note[a[start]])
{
mp[a[start]]--;
start++;
}
else
{
break;
}
}
ans=min(ans, i-start+1);
}
}
if(ans==1e9)printf("impossible\n");
else printf("%d\n", ans);
}
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... |