# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1013748 |
2024-07-04T05:29:38 Z |
vjudge1 |
Martian DNA (BOI18_dna) |
C++17 |
|
32 ms |
3412 KB |
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
using namespace std;
const int N = 2e5+1, INF = 1e9;
int n, k, rr;
int a[N];
int q[N];
int cur[N];
int main()
{
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
cin >> n >> k >> rr;
for (int i = 1; i <= n; cin >> a[i++]);
for (int i = 1, b; i <= rr; cin >> b >> q[b], i++);
int sat = (q[a[1]] && ++cur[a[1]] == q[a[1]]);
int l = 1, r = 1;
int sol = INF;
while (r <= n) {
//cerr << l << ' ' << r << endl;
if (sat == rr && l < r) {
sol = min(sol, r-l+1);
cur[a[l]]--;
if (q[a[l]] && cur[a[l]] == q[a[l]]-1) sat--;
l++;
} else {
r++;
cur[a[r]]++;
if (q[a[r]] && cur[a[r]] == q[a[r]]) sat++;
}
}
cout << (sol == INF ? "impossible" : to_string(sol));
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
476 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
464 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Incorrect |
1 ms |
428 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
1628 KB |
Output is correct |
2 |
Correct |
8 ms |
1624 KB |
Output is correct |
3 |
Correct |
15 ms |
1608 KB |
Output is correct |
4 |
Correct |
8 ms |
1628 KB |
Output is correct |
5 |
Correct |
13 ms |
2652 KB |
Output is correct |
6 |
Correct |
7 ms |
1628 KB |
Output is correct |
7 |
Correct |
8 ms |
1744 KB |
Output is correct |
8 |
Correct |
13 ms |
3160 KB |
Output is correct |
9 |
Correct |
11 ms |
2224 KB |
Output is correct |
10 |
Correct |
7 ms |
1588 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
604 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
468 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
23 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
32 ms |
3412 KB |
Output is correct |
2 |
Correct |
16 ms |
3164 KB |
Output is correct |
3 |
Correct |
14 ms |
2792 KB |
Output is correct |
4 |
Incorrect |
8 ms |
1624 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |