# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
121462 | 2019-06-26T14:22:04 Z | TadijaSebez | Garage (IOI09_garage) | C++11 | 3 ms | 384 KB |
#include <stdio.h> #include <vector> #include <algorithm> #include <set> #include <queue> using namespace std; const int N=2050; int r[N],w[N],my[N]; set<int> Free; queue<int> q; int main() { int n,m,i,sol=0,x; scanf("%i %i",&n,&m); for(i=1;i<=n;i++) scanf("%i",&r[i]),Free.insert(i); for(i=1;i<=m;i++) scanf("%i",&w[i]); for(i=1;i<=m*2;i++) { scanf("%i",&x); if(x>0) q.push(x); else x=-x,Free.insert(my[x]); while(q.size() && Free.size()) { int car=q.front(); q.pop(); int space=*Free.begin(); Free.erase(space); my[car]=space; sol+=r[space]*w[car]; } } printf("%i\n",sol); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 3 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 2 ms | 384 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 | 384 KB | Output is correct |
9 | Correct | 2 ms | 384 KB | Output is correct |
10 | Correct | 2 ms | 384 KB | Output is correct |
11 | Correct | 2 ms | 384 KB | Output is correct |
12 | Correct | 2 ms | 384 KB | Output is correct |
13 | Correct | 2 ms | 384 KB | Output is correct |
14 | Correct | 2 ms | 384 KB | Output is correct |
15 | Correct | 2 ms | 384 KB | Output is correct |
16 | Correct | 3 ms | 384 KB | Output is correct |
17 | Correct | 3 ms | 384 KB | Output is correct |
18 | Correct | 3 ms | 384 KB | Output is correct |
19 | Correct | 2 ms | 384 KB | Output is correct |
20 | Correct | 3 ms | 384 KB | Output is correct |