이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
int n, l, ans = 0;
cin >> n >> l;
int a[n+10], b[n+10], x[n+10];
for(int i = 1; i <= n; i++) {
cin >> a[i];
}
a[0] = 0;
for(int i = 1; i <= n; i++) cin >> x[i];
int gg = n;
for(int i = 1; i <= n; ++i) {
b[gg] = fabs(l - a[i]);
gg--;
}
b[n+1] = 0;
b[0] = 0;
x[0] = 0;
int dex = 0;
for(int i = 0; i <= n; i++) {
int cnt = 0;
dex += b[i];
if(dex <= x[n - (i - 1)] && i > 0) cnt++;
int gs = dex * 2;
for(int j = 1; j <= n - i; j++) {
gs += fabs(a[j-1] - a[j]);
cnt += (gs <= x[j]);
}
ans = max(ans, cnt);
}
dex = 0;
for(int i = 0; i <= n; i++) {
int cnt = 0;
dex += a[i];
if(dex <= x[i] && i > 0) cnt++;
int gs = dex * 2;
for(int j = n; j >= 1 + i; j--) {
gs += fabs(b[j + 1] - b[j]);
cnt += (gs <= x[j]);
ans = max(ans, cnt);
}
}
cout << ans << 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... |