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;
using ll = long long;
int main(){
ios::sync_with_stdio(0);cin.tie(0);
ll n,l;
cin >> n >> l;
vector<ll> x(n),t(n);
for(ll &i : x) cin >> i;
for(ll &i : t) cin >> i;
vector<ll> rx(n),rt(n);
for(ll i = 0;i<n;i++){
rx[i] = l-x[n-1-i];
rt[i] = t[n-1-i];
}
ll ans = 0;
{
ll cur = 0;
for(ll i = 0;i<n;i++) cur += t[i]>=x[i];
ans = max(ans,cur);
}
{
ll cur = 0;
for(ll i = 0;i<n;i++) cur += rt[i]>=rx[i];
ans = max(ans,cur);
}
for(ll i = 0;i<n;i++){
ll w = x[i];
ll cur = 0;
for(ll j = 0;j<=i;j++) cur += t[j]>=x[j];
w*=2;
for(ll j = 0;j+i<n-1;j++) cur += rt[j]>=rx[j]+w;
ans = max(ans,cur);
}
for(ll i = 0;i<n;i++){
ll w = rx[i];
ll cur = 0;
for(ll j = 0;j<=i;j++) cur += rt[j]>=rx[j];
w*=2;
for(ll j = 0;j+i<n-1;j++) cur += t[j]>=x[j]+w;
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... |