제출 #1121907

#제출 시각아이디문제언어결과실행 시간메모리
1121907_callmelucian Martian DNA (BOI18_dna)C++14
40 / 100
7 ms2032 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<ll,ll> pl; typedef pair<int,int> pii; typedef tuple<int,int,int> tpl; #define all(a) a.begin(), a.end() #define filter(a) a.erase(unique(all(a)), a.end()) const int mn = 1e5 + 5; int a[mn], delta[mn]; int main() { ios::sync_with_stdio(0); cin.tie(0); int n, k, r; cin >> n >> k >> r; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 0; i < r; i++) { int b, q; cin >> b >> q; delta[b] = -q; } int start = 0; for (int i = 0; i < k; i++) { while (start + 1 <= n && delta[i] < 0) delta[a[++start]]++; if (delta[i] < 0) return cout << "impossible", 0; } int ans = start; for (int L = 1, R = start; R <= n; R++) { if (R != start) delta[a[R]]++; while (L < R && delta[a[L]] > 0) delta[a[L++]]--; ans = min(ans, R - L + 1); } cout << ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...