This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |