Submission #1058685

#TimeUsernameProblemLanguageResultExecution timeMemory
1058685GrayBikeparking (EGOI24_bikeparking)C++17
25 / 100
27 ms6928 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=0; for (ll i=1; i<n; i++){ l=min(l, i); while (l<i 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++; } } for (ll i=0; i<n; i++){ ll rem = min(x[i], y[i]); x[i]-=rem; y[i]-=rem; } 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...