#include <bits/stdc++.h>
#define x first
#define y second
#define pii pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define pbb pair<bool,bool>
#define mp make_pair
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define xmod (ll)(1e9+7)
#define hmod 1286031825167LL
using namespace std;
int n,l,used,ct,ans;
pii a[205];
int left(int x){
ct=0; used=0;
for (int i=n;i>=n-x+1;i--){
used+=a[i+1].x-a[i].x;
if (used <= a[i].y)
ct++;
}
used+=l-a[n-x+1].x;
for (int i=1;i<=n-x;i++){
used+=a[i].x-a[i-1].x;
if (used <= a[i].y)
ct++;
}
return ct;
}
int right(int x){
ct=0; used=0;
for (int i=1;i<=x;i++){
used+=a[i].x-a[i-1].x;
if (used <= a[i].y)
ct++;
}
used+=a[x].x;
for (int i=n;i>=x+1;i--){
used+=a[i+1].x-a[i].x;
if (used <= a[i].y)
ct++;
}
return ct;
}
int main(){
ios::sync_with_stdio(false);
cin >> n >> l;
for (int i=1;i<=n;i++){
cin >> a[i].x;
}
for (int i=1;i<=n;i++){
cin >> a[i].y;
}
a[n+1].x=l;
for (int i=1;i<=n;i++){
ans=max(ans,left(i));
ans=max(ans,right(i));
}
cout << ans << "\n";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |