# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
715369 | Toxtaq | Garage (IOI09_garage) | C++17 | 3 ms | 340 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
int main()
{
int spaces, cars;
long long result = 0;
cin >> spaces >> cars;
vector<int>rate(spaces + 1), weights(cars + 1);
for(int i = 1;i <= spaces;++i)cin >> rate[i];
for(int i = 1;i <= cars;++i)cin >> weights[i];
vector<int>parking(spaces + 1);
queue<int>q;
for(int i = 0;i < 2 * cars;++i){
int car;
bool parked = false;
cin >> car;
if(car > 0){
for(int j = 1;j <= spaces;++j){
if(!parking[j]){
parking[j] = car;
result += weights[car] * rate[j];
parked = true;
break;
}
}
if(!parked){
q.push(car);
}
}
else{
for(int j = 1;j <= spaces;++j){
if(-car == parking[j]){
parking[j] = 0;
break;
}
}
if(!q.empty()){
int cur = q.front();
q.pop();
for(int j = 1;j <= spaces;++j){
if(!parking[j]){
parking[j] = cur;
result += weights[cur] * rate[j];
break;
}
}
}
}
}
cout << result;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |