| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 720620 | AnjaJ | Garage (IOI09_garage) | C++14 | 2 ms | 364 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... | ||||
