Submission #382525

#TimeUsernameProblemLanguageResultExecution timeMemory
382525ritul_kr_singh Martian DNA (BOI18_dna)C++17
100 / 100
39 ms3436 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define sp << " " << #define nl << "\n" signed main(){ cin.tie(0)->sync_with_stdio(0); int n, k, r; cin >> n >> k >> r; int a[n], b[k]; fill(b, b+k, -n); for(int i=0; i<n; ++i) cin >> a[i]; for(int i=0, j; i<r; ++i) cin >> j >> b[j]; int i = 0, curr = n-r, ans = 1e18; for(int j=0; j<n; ++j){ curr += --b[a[j]]==0; while(i<j and b[a[i]] < 0) ++b[a[i++]]; if(curr==n) ans = min(ans, j-i+1); } if(ans==(int)1e18) cout << "impossible"; else 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...