| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1151545 | KaleemRazaSyed | Bikeparking (EGOI24_bikeparking) | C++20 | 75 ms | 2760 KiB |
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin >> n;
int x[n], y[n];
for(int i = 0; i < n; i ++)
cin >> x[i];
for(int i = 0; i < n; i ++)
cin >> y[i];
long long sm = 0;
for(int i = 0; i < n; i ++)
sm += y[i];
for(int i = 0; i < n; i ++)
{
x[i] = min(sm, (long long)x[i]);
sm -= x[i];
}
int ans = 0;
int s = 0, e = n - 1;
for(int i = 0; i < n; i++)
{
while(y[i] > 0)
{
if(i > s)
{
int mi = min(y[i], x[s]);
x[s] -= mi;
y[i] -= mi;
if(i > s) ans += mi;
if(!x[s]) s++;
}
else
{
int mi = min(y[i], x[e]);
x[e] -= mi;
y[i] -= mi;
if(e > i) ans -= mi;
if(!x[e]) e--;
}
}
}
cout << ans << endl;
return 0;
}
| # | 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... | ||||
