이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |