답안 #630584

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
630584 2022-08-16T15:41:19 Z lucri Garage (IOI09_garage) C++17
100 / 100
3 ms 340 KB
#include <bits/stdc++.h>
using namespace std;
int n,m,r[110],g[2010],p[2010],x,ans;
priority_queue<int>a;
queue<int>b;
int main()
{
    cin>>n>>m;
    for(int i=1;i<=n;++i)
    {
        a.push(-i);
        cin>>r[i];
    }
    for(int i=1;i<=m;++i)
    {
        cin>>g[i];
    }
    m*=2;
    for(int i=1;i<=m;++i)
    {
        cin>>x;
        if(x<0)
            a.push(-p[-x]);
        else
        {
            b.push(x);
        }
        if(!b.empty()&&!a.empty())
        {
            int z=-a.top();
            a.pop();
            int poz=b.front();
            b.pop();
            p[poz]=z;
            ans+=g[poz]*r[z];
        }
    }
    cout<<ans;
    return 0;
}
# 결과 실행 시간 메모리 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 304 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 304 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 2 ms 340 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 3 ms 340 KB Output is correct