답안 #239010

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
239010 2020-06-14T04:57:51 Z Autoratch Garage (IOI09_garage) C++14
100 / 100
5 ms 384 KB
#include <bits/stdc++.h>
using namespace std;

const int N = 2001;

int n,m,ans;
int rates[N],wei[N],slot[N];
priority_queue<int,vector<int>,greater<int> > q;
queue<int> car;

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

    cin >> n >> m;
    for(int i = 1;i <= n;i++) cin >> rates[i],q.push(i);
    for(int i = 1;i <= m;i++) cin >> wei[i];
    for(int i = 0;i < m*2;i++)
    {
        int x;
        cin >> x;
        if(x>0) car.push(x);
        else q.push(slot[-x]);
        if(!q.empty() and !car.empty())
        {
            slot[car.front()] = q.top();
            q.pop(),car.pop();
        }
    }
    for(int i = 1;i <= m;i++) ans+=rates[slot[i]]*wei[i];
    cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct