Submission #1133049

#TimeUsernameProblemLanguageResultExecution timeMemory
1133049lopkus Martian DNA (BOI18_dna)C++20
40 / 100
2092 ms8264 KiB
#include <bits/stdc++.h> #define int long long using namespace std; signed main() { ios::sync_with_stdio(false); cin.tie(0); int n, dic, r; cin >> n >> dic >> r; vector<int> a(n + 1); for(int i = 1; i <= n; i++) { cin >> a[i]; } int ans = n + 1; vector<int> p(r + 1); vector<int> k(r + 1); for(int i = 1; i <= r; i++) { cin >> p[i] >> k[i]; } for(int i = 1; i <= n; i++) { map<int,int> M; for(int j = i; j <= n; j++) { M[a[j]] += 1; int ok = 1; for(int q = 1; q <= r; q++) { if(M[p[q]] >= k[q]) { } else { ok = 0; } } if(ok) { ans = min(ans, j - i + 1); } } } if(ans == n + 1) { 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...