# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1013672 | canadavid1 | Garage (IOI09_garage) | C++17 | 2 ms | 604 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
int main()
{
int N,M;
std::cin >> N >> M;
std::vector<int> rate(N);
for(auto& i : rate) std::cin >> i;
std::vector<int> weight(M);
for(auto& i : weight) std::cin >> i;
weight.emplace(weight.begin()); // 1-indexing
std::vector<int> spaces;
for(int i = 0; i < N; i++) spaces.push_back(i);
std::queue<int> q;
std::vector<int> space(N+1);
long long c = 0;
for(int i = 0; i < 2*M; i++)
{
int op;
std::cin >> op;
if(op > 0)
q.push(op);
else
spaces.push_back(space[-op]);
while(q.size() && spaces.size())
{
auto car = q.front(); q.pop();
auto p = std::min_element(spaces.begin(),spaces.end());
auto sp = *p; spaces.erase(p);
space[car] = sp;
c += weight[car] * rate[sp];
}
}
std::cout << c << "\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |