#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fr first
#define sc second
#define all(x) (x).begin(), (x).end()
const int MOD = 1e9 + 7;
const int MAXN = 2e2 + 5;
const long long INF = 1e18 + 5;
int n, d;
vector<int> t(MAXN), x(MAXN);
int dist(int a, int b) {
if(b >= a) return min(x[b] - x[a], d - (x[b] - x[a]));
return min(x[a] - x[b], d - (x[a] - x[b]));
}
int32_t main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cin >> n >> d;
for(int i = 1; i <= n; i++) cin >> x[i];
for(int i = 1; i <= n; i++) cin >> t[i];
int ans = 0;
for(int mask = 0; mask < (1<<n); mask++) {
int l = 0, r = 0, cur = 0, time = 0, tot = 0;
for(int i = 0; i < n; i++) {
if(mask & (1<<i)) {
r = (r + 1) % (n + 1);
time += dist(cur, r);
if(time <= t[r]) tot++;
cur = r;
}
else {
l = (l + n) % (n + 1);
time += dist(cur,l);
if(time <= t[l]) tot++;
cur = l;
}
}
ans = max(tot, ans);
}
cout << ans << "\n";
return 0;
}
# | 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... |