# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
545589 | 2022-04-04T23:21:58 Z | pere_gil | Garage (IOI09_garage) | C++17 | 1 ms | 340 KB |
#include "bits/stdc++.h" using namespace std; int main(){ int n,m; scanf("%d %d",&n,&m); vector<int> r(n+1); for(int i=1;i<=n;i++) scanf("%d",&r[i]); vector<int> h(m+1); for(int i=1;i<=m;i++) scanf("%d",&h[i]); queue<int> car; priority_queue<int,vector<int>,greater<int>> parking; for(int i=n;i>0;i--) parking.push(i); vector<int> v(m+1); m*=2; long long res=0; while(m--){ int act; scanf("%d",&act); if(act>0){ if(parking.empty()) car.push(act); else{ v[act]=parking.top(); parking.pop(); res+=h[act]*r[v[act]]; } } else{ parking.push(v[-act]); if(!car.empty()){ act=car.front(); car.pop(); v[act]=parking.top(); parking.pop(); res+=h[act]*r[v[act]]; } } } printf("%lld\n",res); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 296 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 296 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 | 212 KB | Output is correct |
14 | Correct | 1 ms | 308 KB | Output is correct |
15 | Correct | 1 ms | 212 KB | Output is correct |
16 | Correct | 1 ms | 212 KB | Output is correct |
17 | Correct | 1 ms | 308 KB | Output is correct |
18 | Correct | 1 ms | 312 KB | Output is correct |
19 | Correct | 1 ms | 308 KB | Output is correct |
20 | Correct | 1 ms | 340 KB | Output is correct |