Submission #227949

# Submission time Handle Problem Language Result Execution time Memory
227949 2020-04-29T10:27:24 Z kimbj0709 Garage (IOI09_garage) C++14
100 / 100
5 ms 512 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define maxn 2050
int32_t main(){
  ios::sync_with_stdio(0);
  cin.tie(0);cout.tie(0);
  int no_of_space,no_of_car;
  int input1,input2;
  priority_queue<int,vector<int>,greater<int> > q1;
  cin >> no_of_space >> no_of_car;
  vector<int> price(maxn);
  vector<int> weight(maxn);
  for(int i=1;i<=no_of_space;i++){
    q1.push(i);
    cin >> input1;
    price[i] = input1;
  }
  for(int i=1;i<=no_of_car;i++){
    cin >> input1;
    weight[i] = input1;
  }
  int ans = 0;
  vector<int> taken(maxn,0);
  deque<int> q2;
  for(int i=0;i<2*no_of_car;i++){
    cin >> input1;
    if(input1>0){//enter
      q2.push_back(input1);
    }
    else{
      input1 *= -1;
      q1.push(taken[input1]);
      taken[input1] = 0;
    }
    while(q1.size()!=0&&q2.size()!=0){
      ans += weight[q2.front()]*price[q1.top()];
      taken[q2.front()] = q1.top();
      q1.pop();q2.pop_front();
    }
  }
  cout << ans;
}

Compilation message

garage.cpp: In function 'int32_t main()':
garage.cpp:9:14: warning: unused variable 'input2' [-Wunused-variable]
   int input1,input2;
              ^~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 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 5 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 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 256 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 512 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct