#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<pair<int,int>,int>vis;
void solve(int start,int time,set<int>have){
vis[{start,time}]=1;
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];
if(!vis.count({0,time+sum}))
solve(0,time+sum,have);
}
else{
if(!vis.count({you,time+(x[you]-x[start])}))
solve(you,time+(x[you]-x[start]),have);
}
you = start-1;
if(you==-1){
int sum = x[start]+l-x[n-1];
if(!vis.count({n-1,time+sum}))
solve(n-1,time+sum,have);
}
else{
if(!vis.count({you,time+(x[start]-x[you])}))
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 |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |