Submission #943319

# Submission time Handle Problem Language Result Execution time Memory
943319 2024-03-11T10:40:39 Z maxFedorchuk Garage (IOI09_garage) C++17
0 / 100
1 ms 2396 KB
#include <bits/stdc++.h>
using namespace std;

const long long MX=2e5+10;

int msq[MX],w[MX],cs[MX],ans=0;

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

    priority_queue < pair < int , int > , vector < pair < int , int > > , greater < pair < int , int > > > qp;

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

    for(int i=1;i<=n;i++)
    {
        cin>>cs[i];
        qp.push({cs[i],i});
    }

    for(int i=1;i<=m;i++)
    {
        cin>>w[i];
    }

    queue < int > qm;
    for(int i=1;i<=2*m;i++)
    {
        int a;
        cin>>a;

        if(a>0)
        {
            qm.push(a);
        }
        else
        {
            a=(-a);
            qp.push({cs[msq[a]],msq[a]});
            msq[a]=0;
        }

        if(!qp.empty() && !qm.empty())
        {
            int o1=qp.top().second;
            qp.pop();

            int o2=qm.front();
            qm.pop();

            ans+=w[o2]*cs[o1];
            msq[o2]=o1;
        }
    }

    cout<<ans<<"\n";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2392 KB Output isn't correct
2 Incorrect 1 ms 2396 KB Output isn't correct
3 Incorrect 1 ms 2396 KB Output isn't correct
4 Incorrect 1 ms 2392 KB Output isn't correct
5 Incorrect 1 ms 2392 KB Output isn't correct
6 Incorrect 1 ms 2392 KB Output isn't correct
7 Incorrect 1 ms 2396 KB Output isn't correct
8 Incorrect 1 ms 2396 KB Output isn't correct
9 Incorrect 0 ms 2396 KB Output isn't correct
10 Incorrect 1 ms 2396 KB Output isn't correct
11 Incorrect 1 ms 2396 KB Output isn't correct
12 Incorrect 1 ms 2396 KB Output isn't correct
13 Incorrect 1 ms 2396 KB Output isn't correct
14 Incorrect 1 ms 2396 KB Output isn't correct
15 Incorrect 1 ms 2396 KB Output isn't correct
16 Incorrect 1 ms 2396 KB Output isn't correct
17 Incorrect 1 ms 2392 KB Output isn't correct
18 Incorrect 1 ms 2396 KB Output isn't correct
19 Incorrect 1 ms 2396 KB Output isn't correct
20 Incorrect 1 ms 2396 KB Output isn't correct