# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
172557 | 2020-01-02T02:47:47 Z | mcl2000 | Garage (IOI09_garage) | C++ | 3 ms | 504 KB |
#include<bits/stdc++.h> using namespace std; bool lleno[105], pila=true; int dinero[105], carro[2010], hola[105], t; queue<int>numeros; int a, b, g; long long int cont=0; int main() { scanf("%d %d", &a, &b); for(int i=1; i<a+1; i++) { scanf("%d", &dinero[i]); lleno[i]=false; } for(int i=1; i<b+1; i++) { scanf("%d", &carro[i]); } for(int i=0; i<2*b; i++) { scanf("%d", &g); if(g>0) { for(int j=1; j<a+1; j++) { pila=true; if(lleno[j]==false) { cont+=(dinero[j]*carro[g]); hola[j]=g; lleno[j]=true; pila=false; break; } } if(pila!=false) { numeros.push(g); } } else { if(g<0) { for(int j=1; j<a+1; j++) { if(hola[j]==g*(-1)) { lleno[j]=false; if(!numeros.empty()) { t=numeros.front(); numeros.pop(); cont+=(dinero[j]*carro[t]); hola[j]=t; lleno[j]=true; } break; } } } } } printf("%lld", cont); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 504 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 0 ms | 356 KB | Output is correct |
4 | Correct | 2 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 256 KB | Output is correct |
7 | Correct | 2 ms | 256 KB | Output is correct |
8 | Correct | 2 ms | 256 KB | Output is correct |
9 | Correct | 2 ms | 256 KB | Output is correct |
10 | Correct | 1 ms | 376 KB | Output is correct |
11 | Correct | 2 ms | 256 KB | Output is correct |
12 | Correct | 2 ms | 376 KB | Output is correct |
13 | Correct | 2 ms | 376 KB | Output is correct |
14 | Correct | 2 ms | 376 KB | Output is correct |
15 | Correct | 3 ms | 376 KB | Output is correct |
16 | Correct | 3 ms | 376 KB | Output is correct |
17 | Correct | 3 ms | 376 KB | Output is correct |
18 | Correct | 3 ms | 376 KB | Output is correct |
19 | Correct | 3 ms | 372 KB | Output is correct |
20 | Correct | 3 ms | 376 KB | Output is correct |