Submission #482981

#TimeUsernameProblemLanguageResultExecution timeMemory
482981DJeniUp Martian DNA (BOI18_dna)C++17
0 / 100
83 ms4180 KiB
#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 (stderr)

dna.cpp:1: warning: ignoring '#pragma GCC Optimize' [-Wunknown-pragmas]
    1 | #pragma GCC Optimize("O3")
      |
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...