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;
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 |
---|
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... |