#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
18 ms |
212 KB |
Output is correct |
2 |
Execution timed out |
2086 ms |
416 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
18 ms |
212 KB |
Output is correct |
2 |
Execution timed out |
2086 ms |
416 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
18 ms |
212 KB |
Output is correct |
2 |
Execution timed out |
2086 ms |
416 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
18 ms |
212 KB |
Output is correct |
2 |
Execution timed out |
2086 ms |
416 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |