#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main() {
ios::sync_with_stdio(0); cin.tie(0);
int n, l;
cin >> n >> l;
int x[n];
for (int i = 0; i < n; i++) cin >> x[i];
int t[n];
for (int i = 0; i < n; i++) cin >> t[i];
int ans = 0;
for (int sl = 0; sl <= n; sl++) {
for (int sr = 0; sl + sr <= n; sr++) {
int cost;
int cur1 = 0; cost = (sl == 0 ? 0 : x[sl - 1]) * 2;
for (int i = 0; i < sl; i++) cur1 += (x[i] <= t[i]);
for (int i = n - 1; i >= n - sr; i--) cur1 += (cost + (l - x[i]) <= t[i]);
int cur2 = 0; cost = (sr == 0 ? 0 : x[n - sr]) * 2;
for (int i = n - 1; i >= n - sr; i--) cur2 += ((l - x[i]) <= t[i]);
for (int i = 0; i < sl; i++) cur2 += ((cost + x[i]) <= t[i]);
ans = max(ans, max(cur1, cur2));
}
}
cout << ans << '\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
1 ms |
500 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
1 ms |
500 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
1 ms |
500 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
1 ms |
500 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |