Submission #1071429

#TimeUsernameProblemLanguageResultExecution timeMemory
1071429vjudge1Collecting Stamps 3 (JOI20_ho_t3)C++17
0 / 100
0 ms348 KiB
#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; int dex = 0; for(int i = 1; i <= n; i++) { int cnt = 0;; dex += b[i]; if(dex <= x[n - (i - 1)]) cnt++; int gs = dex * 2; for(int j = 1; j <= n - i; j++) { gs += fabs(a[j-1] - a[j]); cnt += (gs <= x[i]); } ans = max(ans, cnt); } dex = 0; for(int i = 1; i <= n; i++) { int cnt = 0; dex += a[i]; if(dex <= x[i]) 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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...