#include <iostream>
#include <math.h>
using namespace std;
const int MAXN = 1e3;
pair<int, int> t[MAXN];
int best;
int n, l;
void left(){
int act = 0;
for(int i = 1; i <= n; i++){
int tajm = t[i].first;
if(t[i].second >= tajm)
act += 1;
int j = n;
int atmp = 0;
while(j > i){
int tmp = abs(l - t[j].first);
if(t[j].second >= tmp + 2*tajm)
atmp++;
j--;
}
best = max(best, act + atmp);
}
}
void right(){
int act = 0;
for(int i = n; i >=1; i--){
int tajm = abs(l - t[i].first);
if(t[i].second >= tajm)
act += 1;
int j = 1;
int atmp = 0;
while(j < i){
int tmp = t[j].first;
if(t[j].second >= tmp + 2*tajm)
atmp++;
j++;
}
best = max(best, act + atmp);
}
}
int main(){
ios_base::sync_with_stdio();
cin.tie(0);
cin >> n >> l;
for(int i = 1; i <= n; i++)
cin >> t[i].first;
for(int i = 1; i <= n; i++)
cin >> t[i].second;
left();
right();
cout << best << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |