# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
482982 |
2021-10-27T08:44:18 Z |
DJeniUp |
Martian DNA (BOI18_dna) |
C++17 |
|
88 ms |
2584 KB |
#pragma GCC Optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pairll;
typedef pair<ll,pairll>pairlll;
typedef pair<pairll,pairll>pairllll;
typedef long double ld;
typedef pair<ll,string>pairls;
#define INF 1000000000000007
#define MOD 1000000007
#define pb push_back
#define fr first
#define sc second
#define endl '\n'
ll n,k,d[200007],f[200007];
int main() {
cin>>n>>k>>k;
for(int i=1;i<=n;i++){
cin>>d[i];
}
for(int i=1;i<=k;i++){
ll x,y;
cin>>x>>y;
f[x]=y;
}
ll l=1;
ll r=0;
ll res=INF;
for(int i=1;i<=n+1;i++){
while(l<r && f[d[l]]<0){
f[d[l]]++;
l++;
}
r=i;
f[d[r]]--;
if(f[d[r]]==0 && r<=n)k--;
if(k==0)res=min(res,r-l+1);
}
if(res==INF)cout<<"impossible"<<endl;
else cout<<res<<endl;
}
Compilation message
dna.cpp:1: warning: ignoring '#pragma GCC Optimize' [-Wunknown-pragmas]
1 | #pragma GCC Optimize("O3")
|
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
27 ms |
1752 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
88 ms |
2584 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |