# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
720620 |
2023-04-08T17:13:35 Z |
AnjaJ |
Garage (IOI09_garage) |
C++14 |
|
2 ms |
364 KB |
#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 |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
320 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
328 KB |
Output is correct |
7 |
Correct |
1 ms |
324 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
324 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
2 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
364 KB |
Output is correct |