# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1013796 |
2024-07-04T05:59:44 Z |
vjudge1 |
Martian DNA (BOI18_dna) |
C++17 |
|
26 ms |
8592 KB |
//
// main1.cpp
// problem1
//
// Created by Essa Almousa on 2030 / 01/ 01 AD.
//
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
using ll = long long;
#define pb push_back
#define pF first
#define pS second
#define SP <<" "<<
const ll N = 3e5;
ll a[N], req[N], frq[N], ans1[N];
int main() {
ios::sync_with_stdio(0); cout.tie(0); cin.tie(0);
ll n, k, q;
cin>>n>>k>>q;
for (int i=0; i<n; i++) {
cin>>a[i];
ans1[a[i]] = 1;
}
for (int i=0; i<q; i++) {
ll x, y; cin>>x>>y;
req[x] = y;
ans1[x] = 0;
}
ll mn = INT_MAX, l = 0, r = -1;
ll ans = q;
while (r <= n-1 && l <= n-1) {
if (ans == 0) {
mn = min(mn, r-l+1);
}
if (ans != 0) {
r++;
if (r >= n) break;
frq[a[r]]++;
if (req[a[r]] <= frq[a[r]]) {
if (ans1[a[r]] == 0) {
ans1[a[r]] = 1;
ans--;
}
}
}
else if (ans == 0) {
frq[a[l]]--;
if (req[a[l]] > frq[a[l]]) {
if (ans1[a[l]] == 1) {
ans1[a[l]] = 0;
ans++;
}
}
l++;
}
}
if (ans == 0) {
mn = min(mn, r-l+1);
}
if (mn == INT_MAX) cout << "impossible";
else cout << mn;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
0 ms |
4444 KB |
Output is correct |
3 |
Correct |
0 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
4444 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
1 ms |
4444 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4440 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4440 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
4444 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
1 ms |
4444 KB |
Output is correct |
10 |
Correct |
0 ms |
4444 KB |
Output is correct |
11 |
Correct |
1 ms |
4444 KB |
Output is correct |
12 |
Correct |
1 ms |
4444 KB |
Output is correct |
13 |
Correct |
1 ms |
4444 KB |
Output is correct |
14 |
Correct |
1 ms |
4444 KB |
Output is correct |
15 |
Correct |
1 ms |
4444 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
4700 KB |
Output is correct |
2 |
Correct |
8 ms |
4700 KB |
Output is correct |
3 |
Correct |
8 ms |
4560 KB |
Output is correct |
4 |
Correct |
9 ms |
4700 KB |
Output is correct |
5 |
Correct |
12 ms |
7652 KB |
Output is correct |
6 |
Correct |
7 ms |
4560 KB |
Output is correct |
7 |
Correct |
8 ms |
4700 KB |
Output is correct |
8 |
Correct |
13 ms |
8592 KB |
Output is correct |
9 |
Correct |
10 ms |
4696 KB |
Output is correct |
10 |
Correct |
7 ms |
4568 KB |
Output is correct |
11 |
Correct |
1 ms |
4440 KB |
Output is correct |
12 |
Correct |
1 ms |
4444 KB |
Output is correct |
13 |
Correct |
1 ms |
4444 KB |
Output is correct |
14 |
Correct |
1 ms |
4596 KB |
Output is correct |
15 |
Correct |
1 ms |
4444 KB |
Output is correct |
16 |
Correct |
1 ms |
4444 KB |
Output is correct |
17 |
Correct |
1 ms |
4444 KB |
Output is correct |
18 |
Correct |
1 ms |
4444 KB |
Output is correct |
19 |
Correct |
0 ms |
4444 KB |
Output is correct |
20 |
Correct |
1 ms |
4444 KB |
Output is correct |
21 |
Correct |
0 ms |
4444 KB |
Output is correct |
22 |
Correct |
1 ms |
4444 KB |
Output is correct |
23 |
Correct |
1 ms |
4444 KB |
Output is correct |
24 |
Correct |
1 ms |
4444 KB |
Output is correct |
25 |
Correct |
1 ms |
4444 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
7508 KB |
Output is correct |
2 |
Correct |
16 ms |
7260 KB |
Output is correct |
3 |
Correct |
17 ms |
7256 KB |
Output is correct |
4 |
Correct |
7 ms |
4700 KB |
Output is correct |
5 |
Correct |
20 ms |
7564 KB |
Output is correct |
6 |
Correct |
25 ms |
8300 KB |
Output is correct |
7 |
Correct |
11 ms |
4696 KB |
Output is correct |
8 |
Correct |
14 ms |
4952 KB |
Output is correct |
9 |
Correct |
7 ms |
4700 KB |
Output is correct |
10 |
Correct |
8 ms |
4700 KB |
Output is correct |
11 |
Correct |
11 ms |
4696 KB |
Output is correct |
12 |
Correct |
10 ms |
4700 KB |
Output is correct |
13 |
Correct |
12 ms |
7512 KB |
Output is correct |
14 |
Correct |
7 ms |
4700 KB |
Output is correct |
15 |
Correct |
10 ms |
4700 KB |
Output is correct |
16 |
Correct |
13 ms |
8540 KB |
Output is correct |
17 |
Correct |
10 ms |
4880 KB |
Output is correct |
18 |
Correct |
8 ms |
4700 KB |
Output is correct |
19 |
Correct |
1 ms |
4444 KB |
Output is correct |
20 |
Correct |
1 ms |
4444 KB |
Output is correct |
21 |
Correct |
1 ms |
4440 KB |
Output is correct |
22 |
Correct |
1 ms |
4444 KB |
Output is correct |
23 |
Correct |
1 ms |
4444 KB |
Output is correct |
24 |
Correct |
1 ms |
4444 KB |
Output is correct |
25 |
Correct |
1 ms |
4444 KB |
Output is correct |
26 |
Correct |
1 ms |
4444 KB |
Output is correct |
27 |
Correct |
1 ms |
4696 KB |
Output is correct |
28 |
Correct |
1 ms |
4440 KB |
Output is correct |
29 |
Correct |
1 ms |
4444 KB |
Output is correct |
30 |
Correct |
1 ms |
4444 KB |
Output is correct |
31 |
Correct |
0 ms |
4444 KB |
Output is correct |
32 |
Correct |
1 ms |
4444 KB |
Output is correct |
33 |
Correct |
1 ms |
4444 KB |
Output is correct |