| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1329437 | liptonek | Bikeparking (EGOI24_bikeparking) | C++20 | 32 ms | 7468 KiB |
#include <bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin>>n;
vector<long long> x(n);
for(int i=0; i<n; i++)
{
cin>>x[i];
}
vector<long long> y(n);
long long users=0;
for(int i=0; i<n; i++)
{
cin>>y[i];
users+=y[i];
}
vector<long long> u(n,0);
long long assigned=0;
for(int i=0; i<n; i++)
{
long long take=min(x[i],users-assigned);
u[i]=take;
assigned+=take;
if(assigned==users)
{
break;
}
}
int sl=0;
int sh=n-1;
int tl=0;
int th=n-1;
long long score=0;
while(sl<=sh && tl<=th)
{
while(sl<=sh && y[sl]==0)
{
sl++;
}
while(sl<=sh && y[sh]==0)
{
sh--;
}
while(tl<=th && u[tl]==0)
{
tl++;
}
while(tl<=th && u[th]==0)
{
th--;
}
if(sl>sh || tl>th)
{
break;
}
if(sh>th)
{
long long count=min(y[sh],u[th]);
score+=count;
y[sh]-=count;
u[th]-=count;
}
else if(sl>tl)
{
long long count=min(y[sl],u[tl]);
score+=count;
y[sl]-=count;
u[tl]-=count;
}
else
{
long long count=min(y[sl],u[th]);
if(sl<th)
{
score-=count;
}
y[sl]-=count;
u[th]-=count;
}
}
cout<<score<<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... | ||||
