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 <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 |
---|
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... |