# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
545581 | 2022-04-04T23:13:32 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; stack<int> place; int res=0; for(int i=n;i>0;i--) place.push(i); vector<int> v(m+1); for(int i=0;i<2*m;i++){ int act; scanf("%d",&act); if(act>0){ if(place.empty()) car.push(act); else{ v[act]=place.top(); //printf("putting car %d in %d so + %d * %d -> %d\n",act,place.top(),h[act],r[v[act]],h[act]*r[v[act]]); res+=h[act]*r[v[act]]; place.pop(); } } else{ place.push(v[-act]); if(!car.empty()){ v[car.front()]=place.top(); //printf("r putting car %d in %d so + %d * %d -> %d\n",car.front(),place.top(),h[car.front()],r[v[car.front()]],h[car.front()]*r[v[car.front()]]); res+=h[car.front()]*r[v[car.front()]]; place.pop(); car.pop(); } } } printf("%d\n",res); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 256 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Incorrect | 1 ms | 212 KB | Output isn't correct |
5 | Incorrect | 1 ms | 296 KB | Output isn't correct |
6 | Correct | 0 ms | 296 KB | Output is correct |
7 | Incorrect | 1 ms | 212 KB | Output isn't correct |
8 | Incorrect | 1 ms | 212 KB | Output isn't correct |
9 | Incorrect | 1 ms | 212 KB | Output isn't correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Incorrect | 1 ms | 212 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 | 212 KB | Output isn't correct |
15 | Incorrect | 1 ms | 320 KB | Output isn't correct |
16 | Incorrect | 1 ms | 308 KB | Output isn't correct |
17 | Incorrect | 1 ms | 212 KB | Output isn't correct |
18 | Incorrect | 1 ms | 340 KB | Output isn't correct |
19 | Correct | 1 ms | 340 KB | Output is correct |
20 | Incorrect | 1 ms | 340 KB | Output isn't correct |