Submission #1124444

#TimeUsernameProblemLanguageResultExecution timeMemory
1124444henriess Martian DNA (BOI18_dna)C++20
0 / 100
245 ms14332 KiB
#include <bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n,k,r;cin >> n >> k >> r; vector<long long> v(n); set<long long> s; map<long long,long long> m; for(int i = 0;i<n;i++){ cin >> v[i]; } for(int i = 0;i<r;i++){ long long gene,required; cin >> gene >> required; m[gene] = required; } long long left = 0; long long current = 0; long long ans = LLONG_MAX; long long completed = 0; map<long long, long long> track; for(int i = 0;i<n;i++){ if (track[v[i]] == 0){ track[v[i]] = 1; } else{ track[v[i]] += 1; } if (track[v[i]] >= m[v[i]] && m[v[i]] != 0){ completed += 1; } while (completed >= r){ ans = min(ans,i - left+ 1); track[v[left]]--; if (track[v[left]] <=r && m[v[left]] > 0){ completed--; } left++; } } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...