# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
224024 | cheeheng | Collecting Stamps 3 (JOI20_ho_t3) | C++14 | 5 ms | 384 KiB |
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 <bits/stdc++.h>
using namespace std;
int X[205];
int T[205];
int main(){
int N, L;
scanf("%d%d", &N, &L);
X[0] = 0;
for(int i = 1; i <= N; i ++){
scanf("%d", &X[i]);
}
X[N+1] = L;
T[0] = 0;
for(int i = 1; i <= N; i ++){
scanf("%d", &T[i]);
}
T[N+1] = 0;
// clockwise, then anticlockwise
int ans = 0;
for(int i = 0; i <= N; i ++){
int temp = 0;
long long t_taken = 0;
for(int k = 1; k <= i; k ++){
t_taken += X[k]-X[k-1];
if(t_taken <= T[k]){
temp ++;
}
}
t_taken *= 2;
for(int j = N; j >= i+1; j --){
t_taken += X[j+1]-X[j];
if(t_taken <= T[j]){
temp ++;
}
}
ans = max(temp, ans);
}
// anticlockwise, then clockwise
for(int i = 0; i <= N; i ++){
int temp = 0;
long long t_taken = 0;
for(int j = N; j >= i+1; j --){
t_taken += X[j+1]-X[j];
if(t_taken <= T[j]){
temp ++;
}
}
t_taken *= 2;
for(int k = 1; k <= i; k ++){
t_taken += X[k]-X[k-1];
if(t_taken <= T[k]){
temp ++;
}
}
ans = max(temp, ans);
}
printf("%d", ans);
return 0;
}
Compilation message (stderr)
# | 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... |