제출 #1166527

#제출 시각아이디문제언어결과실행 시간메모리
1166527tsengangBikeparking (EGOI24_bikeparking)C++20
100 / 100
82 ms9144 KiB
#include <bits/stdc++.h> #define ll long long #define ff first #define ss second #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() #define pb push_back #define ertunt return #define vodka void #define sleepearly ertunt using namespace std; int main() { ll n; cin >> n; vector<ll> a(n); for (ll i = 0; i < n; i++) cin >> a[i]; vector<ll> b(n); for(ll i = 0; i < n; i++){ cin >> b[i]; } ll ans = 0; vector<ll>s; for(ll i = 0; i < n; i++){ while(!s.empty()){ auto it = s.end(); it--; ll j = *it; ll x = min(a[j],b[i]); ans+=x; a[j]-=x; b[i]-=x; if(a[j] == 0)s.pop_back(); else break; } s.pb(i); } for(ll i = 0; i < n;i++){ ans-=max(0ll,b[i] - a[i]); } cout << ans; }
#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...