This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
using namespace std;
int main()
{
int n;
cin>>n;
int slots[n];
int people[n];
int population = 0;
for(int i = 0;i<n;i++)
{
cin>>slots[i];
}
for(int i = 0;i<n;i++)
{
cin>>people[i];
population+=people[i];
}
int free = 0;
int rating = 0;
int u;
for(int i = 0;i<n;i++)
{
population -= people[i];
u = min(free,people[i]);
free -=u;
people[i]-=u;
rating+=u;
if(slots[i]>population)
{
free= population;
rating -=max(people[i]-(slots[i]-population),0);
}
else
{
free+=slots[i];
rating-=people[i];
}
}
cout<<rating;
}
# | 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... |