# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
482981 |
2021-10-27T08:42:50 Z |
DJeniUp |
Martian DNA (BOI18_dna) |
C++17 |
|
83 ms |
4180 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;i++){
while(l<=r && f[d[l]]<0){
f[d[l]]++;
l++;
}
r=i;
f[d[r]]--;
if(f[d[r]]==0)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 |
1 ms |
204 KB |
Output is correct |
2 |
Incorrect |
1 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 |
29 ms |
2184 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
83 ms |
4180 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |