답안 #597012

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
597012 2022-07-15T11:41:04 Z hail Garage (IOI09_garage) C++17
100 / 100
2 ms 468 KB
#include <bits/stdc++.h>

using namespace std;

using ll=long long;




int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n, m;
    cin>>n>>m;

    ll rate[101];
    ll weight[2001];

    priority_queue<int, vector<int>, greater<int>> park_space;

    for(int i=1; i<=n; i++)
    {
        cin>>rate[i];
        park_space.push(i);
    }
    for(int i=1; i<=m; i++)
    {
        cin>>weight[i];
    }

    map<int, int> car_park;

    long long earnings{};

    queue<int> car_q;

    int car;


    for(int i=1; i<=2*m; i++)
    {
        cin>>car;
        if(car>0)
        {
            car_q.push(car);
        }
        else
        {
            park_space.push(car_park[abs(car)]);
        }
        while((not park_space.empty())&&(not car_q.empty()))
        {
            car_park.insert(make_pair(car_q.front(), park_space.top()));
            earnings+= (weight[car_q.front()])*(rate[park_space.top()]);
            car_q.pop();
            park_space.pop();
        }
    }

    cout<<earnings;


}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 468 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 2 ms 348 KB Output is correct