# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
120094 | 2019-06-23T10:22:39 Z | Boxworld | Garage (IOI09_garage) | C++14 | 3 ms | 512 KB |
#include <bits/stdc++.h> using namespace std; const int N=5100; int x,n,m,r[N],w[N],a[N],ans=0; priority_queue<int,vector<int>,greater<int> > pQ;//parklot queue<int> wQ;//waiting char s[N]; int main(){ scanf("%d%d",&m,&n); for (int i=1;i<=m;i++)scanf("%d",&r[i]); for (int i=1;i<=n;i++)scanf("%d",&w[i]); for (int i=1;i<=m;i++)pQ.push(i); for (int i=1;i<=n*2;i++){ scanf("%d",&x); if (x<0){ x*=-1; if (wQ.empty())pQ.push(a[x]); else{int y=wQ.front();wQ.pop();a[y]=a[x];} }else{ if (pQ.empty())wQ.push(x); else {a[x]=pQ.top();pQ.pop();} } } for (int i=1;i<=n;i++)ans+=r[a[i]]*w[i]; printf("%d\n",ans); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 512 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 | 384 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 | 384 KB | Output is correct |
10 | Correct | 2 ms | 256 KB | Output is correct |
11 | Correct | 2 ms | 384 KB | Output is correct |
12 | Correct | 3 ms | 384 KB | Output is correct |
13 | Correct | 2 ms | 384 KB | Output is correct |
14 | Correct | 2 ms | 256 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 | 3 ms | 384 KB | Output is correct |
20 | Correct | 3 ms | 384 KB | Output is correct |