Submission #1058636

#TimeUsernameProblemLanguageResultExecution timeMemory
1058636GrayBikeparking (EGOI24_bikeparking)C++17
0 / 100
18 ms6168 KiB
// #pragma GCC optimize("O3") // #pragma GCC target("avx2") #include <bitset> #include <cassert> #include <cmath> #include <functional> #include <map> #include <math.h> #include <algorithm> #include <iostream> #include <queue> #include <set> #include <vector> #define ll long long #define ull unsigned ll #define ld long double #define ln "\n" #define ff first #define ss second using namespace std; const ll inf=2e18; const ll MOD = 1000000007; void solve(){ ll n; cin >> n; vector<ll> x(n), y(n); for (ll i=0; i<n; i++) cin >> x[i]; for (ll i=0; i<n; i++) cin >> y[i]; ll res=0, l=n; for (ll i=n-1; i>=0; i--){ l=min(l, i); while (l>=0 and y[i]){ ll rem = min(y[i], x[l]); y[i]-=rem; x[l]-=rem; if (l<i) res+=rem; if (!x[l]) l--; } } l=0; for (ll i=0; i<n; i++){ while (l<n and y[i]){ ll rem = min(y[i], x[l]); y[i]-=rem; x[l]-=rem; if (l>i) res-=rem; if (!x[l]) l++; } } cout << res << ln; } int main(){ ios_base::sync_with_stdio(0); cin.tie(nullptr); ll t=1; // cin >> t; while (t--) solve(); }
#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...