# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1096080 |
2024-10-03T17:20:23 Z |
andrewp |
Martian DNA (BOI18_dna) |
C++14 |
|
2000 ms |
18036 KB |
//Dedicated to my love, ivaziva
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
using ll = int64_t;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define dbg(x) cerr<<#x<<": "<<x<<'\n';
#define dbga(A,l_,r_){for(int i_=l_;i_<=r_;i_++)cerr<<A[i_]<<' ';cerr<<'\n';}
#define dbgv(a_){for(auto x_:a_) cerr<<x_<<' ';cerr<<'\n';}
const int maxn = 2e5 + 3;
int n, k, r;
int a[maxn], b[maxn], q[maxn], ps[maxn][20];
bool check(int len) {
for (int i = len; i <= n; i++) {
bool ok = true;
for (int j = 1; j <= r; j++) {
if (ps[i][j] - ps[i - len][j] < q[j]) {
ok = false;
}
}
if (ok) {
return true;
}
}
return false;
}
int32_t main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
cout.tie(nullptr); cerr.tie(nullptr);
cin >> n >> k >> r;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
for (int i = 1; i <= r; i++) {
cin >> b[i] >> q[i];
}
for (int j = 1; j <= r; j++) {
ps[0][j] = 0;
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= r; j++) {
ps[i][j] = ps[i - 1][j] + (a[i] == b[j]);
}
}
int l = 1, r = n, ans = -1;
while (l <= r) {
int mid = (l + r) / 2;
if (check(mid)) {
r = mid - 1;
ans = mid;
} else {
l = mid + 1;
}
}
if (ans == -1) {
cout << "impossible\n";
return 0;
}
cout << ans << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
468 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
344 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 |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
1 ms |
604 KB |
Output is correct |
3 |
Correct |
1 ms |
604 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
1 ms |
604 KB |
Output is correct |
6 |
Correct |
1 ms |
600 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
25 ms |
17244 KB |
Output is correct |
2 |
Correct |
28 ms |
17240 KB |
Output is correct |
3 |
Correct |
19 ms |
17240 KB |
Output is correct |
4 |
Correct |
25 ms |
17244 KB |
Output is correct |
5 |
Correct |
30 ms |
18008 KB |
Output is correct |
6 |
Correct |
17 ms |
17204 KB |
Output is correct |
7 |
Correct |
17 ms |
17260 KB |
Output is correct |
8 |
Correct |
34 ms |
18036 KB |
Output is correct |
9 |
Correct |
27 ms |
17756 KB |
Output is correct |
10 |
Correct |
28 ms |
17244 KB |
Output is correct |
11 |
Correct |
1 ms |
604 KB |
Output is correct |
12 |
Correct |
0 ms |
604 KB |
Output is correct |
13 |
Correct |
1 ms |
604 KB |
Output is correct |
14 |
Correct |
1 ms |
604 KB |
Output is correct |
15 |
Correct |
1 ms |
760 KB |
Output is correct |
16 |
Correct |
1 ms |
604 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
600 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2050 ms |
16212 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |