# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
53450 | 2018-06-30T04:44:15 Z | 김세빈(#1419) | Garage (IOI09_garage) | C++11 | 4 ms | 736 KB |
#include <bits/stdc++.h> using namespace std; int C[111], W[2020], Q[2020], P[2020]; bool K[111]; int n,m,f,r,ans; int main() { int i,j,a; scanf("%d%d",&n,&m); for(i=0;i<n;i++){ scanf("%d",C+i); } for(i=0;i<m;i++){ scanf("%d",W+i); } for(i=0;i<m+m;i++){ scanf("%d",&a); if(a > 0){ a --; Q[++f] = a; } else{ a = -a-1; K[P[a]] = 0; } for(;r<f;r++){ a = Q[r+1]; for(j=0;j<n;j++) if(K[j] == 0) break; if(j >= n) break; ans += C[j] * W[a]; P[a] = j; K[j] = 1; } } printf("%d\n",ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 248 KB | Output is correct |
2 | Correct | 2 ms | 360 KB | Output is correct |
3 | Correct | 2 ms | 432 KB | Output is correct |
4 | Correct | 2 ms | 508 KB | Output is correct |
5 | Correct | 2 ms | 508 KB | Output is correct |
6 | Correct | 2 ms | 508 KB | Output is correct |
7 | Correct | 2 ms | 524 KB | Output is correct |
8 | Correct | 2 ms | 524 KB | Output is correct |
9 | Correct | 2 ms | 556 KB | Output is correct |
10 | Correct | 2 ms | 604 KB | Output is correct |
11 | Correct | 2 ms | 732 KB | Output is correct |
12 | Correct | 2 ms | 732 KB | Output is correct |
13 | Correct | 2 ms | 732 KB | Output is correct |
14 | Correct | 2 ms | 732 KB | Output is correct |
15 | Correct | 2 ms | 732 KB | Output is correct |
16 | Correct | 3 ms | 732 KB | Output is correct |
17 | Correct | 3 ms | 732 KB | Output is correct |
18 | Correct | 3 ms | 732 KB | Output is correct |
19 | Correct | 4 ms | 732 KB | Output is correct |
20 | Correct | 3 ms | 736 KB | Output is correct |