답안 #1013634

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1013634 2024-07-03T17:55:56 Z canadavid1 Garage (IOI09_garage) C++17
5 / 100
1 ms 604 KB
#include <iostream>
#include <vector>
#include <queue>



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::priority_queue<int,std::vector<int>,std::greater<int>> spaces;
    for(int i = 0; i < N; i++) spaces.push(i);
    std::queue<int> queue;
    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)
            queue.push(op);
        else
            spaces.push(space[-op]);
        while(queue.size() && spaces.size())
        {
            auto car = queue.front(); queue.pop();
            auto sp = spaces.top(); spaces.pop();
            space[car] = sp;
            c += weight[car] * rate[sp];
        }
    }
    std::cout << c << "\n";
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 6
2 Runtime error 1 ms 344 KB Execution killed with signal 6
3 Correct 0 ms 348 KB Output is correct
4 Runtime error 1 ms 604 KB Execution killed with signal 11
5 Runtime error 0 ms 348 KB Execution killed with signal 6
6 Runtime error 1 ms 348 KB Execution killed with signal 6
7 Runtime error 0 ms 348 KB Execution killed with signal 6
8 Runtime error 0 ms 348 KB Execution killed with signal 6
9 Runtime error 0 ms 348 KB Execution killed with signal 6
10 Runtime error 0 ms 348 KB Execution killed with signal 6
11 Runtime error 1 ms 348 KB Execution killed with signal 6
12 Runtime error 1 ms 348 KB Execution killed with signal 6
13 Runtime error 1 ms 348 KB Execution killed with signal 6
14 Runtime error 1 ms 348 KB Execution killed with signal 6
15 Runtime error 1 ms 604 KB Execution killed with signal 6
16 Runtime error 1 ms 604 KB Execution killed with signal 6
17 Runtime error 1 ms 604 KB Execution killed with signal 6
18 Runtime error 1 ms 604 KB Execution killed with signal 6
19 Runtime error 1 ms 604 KB Execution killed with signal 11
20 Runtime error 1 ms 604 KB Execution killed with signal 6