| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1354270 | sally | Bikeparking (EGOI24_bikeparking) | C++20 | 72 ms | 7408 KiB |
#include<iostream>
#include<vector>
#include<stack>
using namespace std;
#define int long long
signed main() {
int N;
cin>>N;
vector<int> slot(N+1, 0), person(N+1);
for(int i=0; i<N; i++) cin>>slot[i];
for(int i=0; i<N; i++) cin>>person[i];
int ans = 0;
stack<int> st;
for(int i=0; i<N; i++) {
while(!st.empty() && person[i]) {
int last_idx = st.top();
int take = min(slot[last_idx], person[i]);
slot[last_idx] -= take;
person[i] -= take;
ans += take;
if(slot[last_idx] == 0)
st.pop();
}
st.push(i);
}
for(int i=0; i<N; i++) {
int take = min(slot[i], person[i]);
slot[i] -= take;
person[i] -= take;
}
for(int i=0; i<N; i++) ans -= person[i];
cout<<ans;
}| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
