Submission #891575

#TimeUsernameProblemLanguageResultExecution timeMemory
891575jellybean Martian DNA (BOI18_dna)C++17
16 / 100
2058 ms12488 KiB
#include <bits/stdc++.h> using namespace std; #define int long long signed main(){ ios::sync_with_stdio(0); cin.tie(0); int n,k,r; cin>>n>>k>>r; int arr[n]; map<int,int>m; map<int,int>req; set<int>s; vector<int>v; for(int i=0; i<n; i++) cin>>arr[i]; for(int i=0; i<r; i++){ int a,b; cin>>a>>b; req[a]=b; s.insert(a); v.push_back(a); } int st=0,ans=LLONG_MAX; /*for(int i=0; i<n; i++){ if(req.find(arr[i])!=req.end()) m[arr[i]]++; if(m[arr[i]]>=req[arr[i]] and s.find(arr[i])!=s.end()) s.erase(arr[i]); while(s.empty()){ ans=min(ans,i-st+1); if(req.find(arr[st])!=req.end()){ m[arr[st]]--; if(m[arr[st]]<req[arr[st]]) s.insert(arr[st]); } st++; } } if(ans==LLONG_MAX) cout<<"impossible"; else cout<<ans;*/ for(int i=0; i<n; i++){ for(int j=i; j<n; j++){ for(int x=i; x<=j; x++){ if(req.find(arr[x])!=req.end()) m[arr[x]]++; if(m[arr[x]]>=req[arr[x]] and s.find(arr[x])!=s.end()) s.erase(arr[x]); } if(s.empty()) ans=min(ans,j-i+1); m.clear(); for(auto x: v)s.insert(x); } } if(ans==LLONG_MAX) cout<<"impossible"; else cout<<ans; return 0; }

Compilation message (stderr)

dna.cpp: In function 'int main()':
dna.cpp:21:6: warning: unused variable 'st' [-Wunused-variable]
   21 |  int st=0,ans=LLONG_MAX;
      |      ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...