# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
495434 | 2021-12-18T15:54:27 Z | ToroTN | Garage (IOI09_garage) | C++14 | 2 ms | 336 KB |
#include<bits/stdc++.h> using namespace std; int n,m,hsh[105],w[2005],r[105],car,cnt=0,u,type; queue<int> q; int main() { scanf("%d%d",&n,&m); for(int i=1;i<=n;i++) { scanf("%d",&r[i]); } for(int i=1;i<=m;i++) { scanf("%d",&w[i]); } for(int i=1;i<=2*m;i++) { scanf("%d",&car); if(car>0) { q.push(car); }else { for(int j=1;j<=n;j++) { if(hsh[j]==-car) { hsh[j]=0; } } } while(!q.empty()) { u=q.front(); type=-1; for(int j=1;j<=n;j++) { if(hsh[j]==0) { type=0; hsh[j]=u; cnt+=r[j]*w[u]; break; } } if(type==-1) { break; } q.pop(); } //printf("%d\n",cnt); } printf("%d\n",cnt); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 300 KB | Output is correct |
2 | Correct | 0 ms | 208 KB | Output is correct |
3 | Correct | 1 ms | 300 KB | Output is correct |
4 | Correct | 0 ms | 208 KB | Output is correct |
5 | Correct | 0 ms | 208 KB | Output is correct |
6 | Correct | 0 ms | 208 KB | Output is correct |
7 | Correct | 0 ms | 208 KB | Output is correct |
8 | Correct | 0 ms | 208 KB | Output is correct |
9 | Correct | 1 ms | 208 KB | Output is correct |
10 | Correct | 1 ms | 300 KB | Output is correct |
11 | Correct | 1 ms | 208 KB | Output is correct |
12 | Correct | 1 ms | 208 KB | Output is correct |
13 | Correct | 1 ms | 208 KB | Output is correct |
14 | Correct | 1 ms | 208 KB | Output is correct |
15 | Correct | 1 ms | 308 KB | Output is correct |
16 | Correct | 1 ms | 208 KB | Output is correct |
17 | Correct | 2 ms | 208 KB | Output is correct |
18 | Correct | 2 ms | 304 KB | Output is correct |
19 | Correct | 2 ms | 336 KB | Output is correct |
20 | Correct | 1 ms | 208 KB | Output is correct |