# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
720620 | AnjaJ | Garage (IOI09_garage) | C++14 | 2 ms | 364 KiB |
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 <bits/stdc++.h>
using namespace std;
int ParkSp, Cars;
int Rate[101];
int Weight[2001];
bool Taken[101] = {};
int takenSpace[2001] = {};
int takenSpaces = 0;
int Profit = 0;
queue <int> q;
void enter(int car)
{
if(takenSpaces == ParkSp)
return q.push(car);
for(int i=1; i<=ParkSp; i++)
{
if(Taken[i]) continue;
takenSpace[car] = i;
Taken[i] = true;
Profit+=Rate[i]*Weight[car];
takenSpaces++;
return;
}
}
void leave(int car)
{
takenSpaces--;
Taken[takenSpace[car]] = false;
takenSpace[car] = 0;
while(takenSpaces < ParkSp && !q.empty())
{
enter(q.front());
q.pop();
}
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin>>ParkSp>>Cars;
for(int i=1; i<=ParkSp; i++)
{
cin>>Rate[i];
}
for(int i=1; i<=Cars; i++)
{
cin>>Weight[i];
}
for(int i=1; i<=2*Cars; i++)
{
int car;
cin>>car;
if(car<0)
leave(-car);
else
enter(car);
}
cout<<Profit;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |