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>
#define int long long
#define endl '\n'
using namespace std;
const int N = 205,INF=1e12;
int n , l;
int x[N],t[N];
map<int,int>mp;
int mx=0,mt=0;
map<int,int>vis;
void solve(int start,int time,set<int>have){
//vis[start]=time;
if(time>mt) return;
//cout<<start<<" "<<time<<" "<<mx<<endl;
if(time<=t[start] && !have.count(start)){
have.insert(start);
mx=max(mx,(int)have.size());
}
int you = start+1;
if(you==n){
int sum = l-x[start] + x[0];
solve(0,time+sum,have);
}
else{
solve(you,time+(x[you]-x[start]),have);
}
you = start-1;
if(you==-1){
int sum = x[start]+l-x[n-1];
solve(n-1,time+sum,have);
}
else{
solve(you,time+(x[start]-x[you]),have);
}
}
int32_t main()
{
//freopen("abc.in", "r", stdin);
cin>>n>>l;
for(int i = 0 ; i < n ; i ++){
cin >> x[i] ;
}
for(int i = 0 ; i < n ; i ++){
cin >> t[i];
mt=max(mt,t[i]);
}
solve(n-1,l-(x[n-1]),{});
cout<<mx<<endl;
}
# | 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... |