제출 #732791

#제출 시각아이디문제언어결과실행 시간메모리
732791Roman70Garage (IOI09_garage)C++17
0 / 100
2 ms340 KiB

#include <bits/stdc++.h>
#define forn(i,n) for(int i = 0;i<n;i++)
#define ll long long
#define pb push_back
#define sz(a) a.size()
using namespace std;

struct cmp{


    bool operator()(const int a, const int b){

        return a > b;

    }


};


void solve()
{

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






    int rate[n];

    int w[m];

       priority_queue<int,vector<int>,cmp>loturi;

    int park[m];
       forn(i,n){
           int cost;
           cin >> cost;
           loturi.push(cost);
       }

    forn(i,m){


        cin >> w[i];

    }


    queue<int>c;

    int p = 0;



    forn(i,2*m){

        int car;

        cin >> car;

        if(car > 0){

             if(loturi.size()){
                int pret = loturi.top();

                p += (pret * w[car-1]);

                loturi.pop();

                park[car-1] = pret;







             }

             else c.push(car-1);

        }
        else{
                car*=(-1);

            if(c.size()){
                int cr = c.front();
                c.pop();
                 p += (park[car-1] * w[cr]);
                 park[cr] = park[car-1];

            }
            else loturi.push(park[car-1]);


        }


    }

    cout<<p;




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

 //  freopen("num.txt","r",stdin);

    int t = 1;
 //   cin >> t;
    while(t--) solve();
    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

garage.cpp: In function 'void solve()':
garage.cpp:33:9: warning: unused variable 'rate' [-Wunused-variable]
   33 |     int rate[n];
      |         ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...