# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
467991 | 2021-08-25T19:51:58 Z | starplat | Garage (IOI09_garage) | C++14 | 2 ms | 332 KB |
#include <bits/stdc++.h> using namespace std; int m,n,ad; long long r[105],w[2005],p,tmp,check; bool a[105]; int aa[105]; queue<int> wa; int main() { cin>>n>>m; p=0;check=0; for (int i=1;i<=n;i++){ scanf("%lld",&r[i]); a[i]=true; aa[i]=0; } for (int i=1;i<=m;i++) scanf("%lld",&w[i]); for (int i=0;i<2*m;i++){ scanf("%d",&ad); if (ad>0) { for (int j=1;j<=n;j++){ if (a[j]==true){ a[j]=false; aa[j]=ad; p+=r[j]*w[ad]; break; } else check++; } if (check==n) wa.push(ad); check=0; } else if (ad<0){ for (int j=1;j<=n;j++){ if (aa[j]==ad*-1){ a[j]=true; aa[j]=0; } } if (wa.empty()) continue; else { for (int j=1;j<=n;j++){ if (a[j]==true){ tmp=wa.front(); wa.pop(); a[j]=false; aa[j]=tmp; p+=r[j]*w[tmp]; break; } } } } } cout<<p<<"\n"; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 296 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 0 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 296 KB | Output is correct |
8 | Correct | 1 ms | 204 KB | Output is correct |
9 | Correct | 0 ms | 204 KB | Output is correct |
10 | Correct | 1 ms | 300 KB | Output is correct |
11 | Correct | 1 ms | 204 KB | Output is correct |
12 | Correct | 1 ms | 204 KB | Output is correct |
13 | Correct | 1 ms | 204 KB | Output is correct |
14 | Correct | 1 ms | 204 KB | Output is correct |
15 | Correct | 1 ms | 204 KB | Output is correct |
16 | Correct | 1 ms | 332 KB | Output is correct |
17 | Correct | 1 ms | 332 KB | Output is correct |
18 | Correct | 2 ms | 332 KB | Output is correct |
19 | Correct | 2 ms | 332 KB | Output is correct |
20 | Correct | 2 ms | 332 KB | Output is correct |