# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
53448 | 2018-06-30T04:42:25 Z | 시제연(#2016) | Garage (IOI09_garage) | C++11 | 4 ms | 724 KB |
#include <bits/stdc++.h> using namespace std; const int N = 100, M = 2000; int n, m, a[N], c[N], w[M], p[M], r; queue<int> q; int main(){ scanf("%d%d", &n, &m); for(int i = 0; i < n; i++) scanf("%d", a + i); for(int i = 0; i < m; i++) scanf("%d", w + i); for(m *= 2; m--; ){ int x; scanf("%d", &x); if(x < 0){ x *= -1; x--; c[p[x]] = 0; if(!q.empty()){ c[p[x]] = 1; r += a[p[x]] * w[q.front()]; q.pop(); } } else{ x--; int s = 0; for(int i = 0; i < n; i++){ if(!c[i]){ c[i] = 1; p[x] = i; r += a[i] * w[x]; s = 1; break; } } if(!s) q.push(x); } } printf("%d\n", r); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 504 KB | Output is correct |
2 | Incorrect | 2 ms | 504 KB | Output isn't correct |
3 | Correct | 2 ms | 512 KB | Output is correct |
4 | Incorrect | 2 ms | 524 KB | Output isn't correct |
5 | Correct | 2 ms | 524 KB | Output is correct |
6 | Incorrect | 2 ms | 524 KB | Output isn't correct |
7 | Correct | 2 ms | 524 KB | Output is correct |
8 | Incorrect | 2 ms | 524 KB | Output isn't correct |
9 | Correct | 2 ms | 524 KB | Output is correct |
10 | Incorrect | 2 ms | 540 KB | Output isn't correct |
11 | Correct | 2 ms | 540 KB | Output is correct |
12 | Incorrect | 2 ms | 540 KB | Output isn't correct |
13 | Correct | 3 ms | 540 KB | Output is correct |
14 | Incorrect | 3 ms | 588 KB | Output isn't correct |
15 | Correct | 3 ms | 588 KB | Output is correct |
16 | Incorrect | 3 ms | 716 KB | Output isn't correct |
17 | Incorrect | 3 ms | 724 KB | Output isn't correct |
18 | Incorrect | 3 ms | 724 KB | Output isn't correct |
19 | Incorrect | 4 ms | 724 KB | Output isn't correct |
20 | Incorrect | 4 ms | 724 KB | Output isn't correct |