Submission #1098371

#TimeUsernameProblemLanguageResultExecution timeMemory
1098371ALTAKEXEBikeparking (EGOI24_bikeparking)C++17
16 / 100
33 ms4244 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() { ll n, ans = 0; cin >> n; ll x[100001], y[100001]; for (ll i = 0; i < n; i++) cin >> x[i]; for (ll i = 0; i < n; i++) cin >> y[i]; ll i = 0, j = 1; while (1) { while (i < n && !x[i]) i++; if (i == n) break; if (i >= j) j = i + 1; while (j < n && !y[j]) j++; if (j == n) break; ll curr = min(x[i], y[j]); ans += curr; x[i] -= curr; y[j] -= curr; } for (ll i = 0; i < n; i++) ans -= max(0ll, y[i] - x[i]); cout << ans << endl; 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...