Submission #1098828

#TimeUsernameProblemLanguageResultExecution timeMemory
1098828ALTAKEXEBikeparking (EGOI24_bikeparking)C++17
100 / 100
36 ms5724 KiB
#include <bits/stdc++.h> #define ll long long #define ff first #define ss second #define inf INT_MAX #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define FAR(i, a, b) for (int i = (a); i >= (b); i--) #define all(x) (x.begin(), x.end()) const int MOD = 1e9 + 7; using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; int x[n], y[n]; for (int i = 0; i < n; i++) cin >> x[i]; for (int i = 0; i < n; i++) cin >> y[i]; int h = 0, w = 0, s = 0; for (int i = n - 1; i > -1; i--) { int x1 = min(w, x[i]); x[i] -= x1; w -= x1; int x2 = min(s, x[i]); s -= x2; x[i] -= x2; h += x1 + x2; s += min(x[i], y[i]); w += y[i] - min(x[i], y[i]); } cout << h - w << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...