Submission #732791

# Submission time Handle Problem Language Result Execution time Memory
732791 2023-04-29T09:57:49 Z Roman70 Garage (IOI09_garage) C++17
0 / 100
2 ms 340 KB
#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;
}

Compilation message

garage.cpp: In function 'void solve()':
garage.cpp:33:9: warning: unused variable 'rate' [-Wunused-variable]
   33 |     int rate[n];
      |         ^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Incorrect 0 ms 316 KB Output isn't correct
3 Incorrect 1 ms 320 KB Output isn't correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Incorrect 1 ms 212 KB Output isn't correct
6 Incorrect 1 ms 212 KB Output isn't correct
7 Incorrect 1 ms 316 KB Output isn't correct
8 Incorrect 1 ms 320 KB Output isn't correct
9 Incorrect 1 ms 212 KB Output isn't correct
10 Incorrect 1 ms 212 KB Output isn't correct
11 Incorrect 1 ms 320 KB Output isn't correct
12 Incorrect 1 ms 212 KB Output isn't correct
13 Incorrect 1 ms 212 KB Output isn't correct
14 Incorrect 1 ms 328 KB Output isn't correct
15 Incorrect 1 ms 328 KB Output isn't correct
16 Incorrect 1 ms 340 KB Output isn't correct
17 Incorrect 2 ms 340 KB Output isn't correct
18 Incorrect 2 ms 340 KB Output isn't correct
19 Incorrect 1 ms 340 KB Output isn't correct
20 Incorrect 1 ms 340 KB Output isn't correct