#include <bits/stdc++.h>
using namespace std;
int main(){
int n, l; cin >> n >> l;
vector<int> X(n), T(n);
for(auto &x : X)cin >> x;
for(auto &t : T)cin >> t;
int ans = 0;
for(int i = 0; i <= n; ++i){
int cur = 0;
int tim = 0;
int place = l;
for(int j = 1; j <= i; ++j){
tim+=place-X[n-j];
place = X[n-j];
if(tim <= T[n-j])cur++;
}
tim*=2;
place = 0;
for(int j = 0; j < n-i; ++j){
tim+=X[j]-place;
place = X[j];
if(tim <= T[j])cur++;
}
ans = max(ans,cur);
}
for(int i = 0; i <= n; ++i){
int cur = 0;
int tim = 0;
int place = 0;
for(int j = 0; j < i; ++j){
tim+=X[j]-place;
place = X[j];
if(tim <= T[j])cur++;
}
tim*=2;
place = l;
for(int j = 1; j <= n-i; ++j){
tim+=place-X[n-j];
place = X[n-j];
if(tim <= T[n-j])cur++;
}
ans = max(ans,cur);
}
cout << ans << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Incorrect |
0 ms |
256 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Incorrect |
0 ms |
256 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Incorrect |
0 ms |
256 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Incorrect |
0 ms |
256 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |