# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
653702 |
2022-10-27T17:58:59 Z |
Juan |
Martian DNA (BOI18_dna) |
C++17 |
|
151 ms |
5212 KB |
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
#define pii pair<int, int>
#define ll long long
int v[maxn], need[maxn];
map<int, int> mp;
int main(){
int n, k, m; cin >> n >> k >> m;
for(int i = 0; i < n; i++) cin >> v[i];
for(int i = 0; i < m; i++){
int a, b; cin >> a >> b;
need[a] = b;
}
int l = 0, r = 0;
int ans = n+1;
while(l<n){
int invalid_cnt = m;
bool term = false;
while(invalid_cnt){
if(r==n) {term = true; break;}
mp[v[r]]++;
if(mp[v[r]]==need[v[r]]) invalid_cnt--;
r++;
}
if(term==true) break;
while(true){
if(mp[v[l]]==need[v[l]]) break;
mp[v[l]]--;
l++;
}
ans = min(ans, r-l);
l = r;
}
if(ans == n+1) cout << "impossible\n";
else cout << ans << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
28 ms |
1072 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
151 ms |
5212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |