# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
275854 | 2020-08-20T08:02:43 Z | barsbold | Garage (IOI09_garage) | C++14 | 8 ms | 384 KB |
#include<bits/stdc++.h> #define pb push_back #define mp make_pair #define ff first #define ss second using namespace std; int r[2001]; int w[2001]; int s[2002]; int vis[2001]; int res =0; int n , m; int main(){ cin >> n; cin >>m; memset(vis , 0 , sizeof(vis)); vector<int> wait; for(int i = 1; i<=n; i++){ cin >> r[i]; } for(int i = 1; i<=m; i++){ cin >> w[i]; } for(int i = 1; i<=m * 2; i++){ int tmp; cin >> tmp; if(tmp > 0){ bool flag =true; for(int i = 1; i<=n; i++){ if(vis[i] == 0){ res+=r[i] * w[tmp]; vis[i] = tmp; flag = false; break; } } if(flag) wait.pb(tmp); } else { int sul ; for(int i = 1; i<=n; i++){ if(vis[i] == tmp * (-1)){ vis[i] = 0; sul = i; } } if(wait.size()!=0) { res+=w[wait[0]] * r[sul]; wait.erase(wait.begin()); } } } cout << res << endl; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 1 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Incorrect | 1 ms | 384 KB | Output isn't correct |
7 | Correct | 1 ms | 384 KB | Output is correct |
8 | Incorrect | 1 ms | 384 KB | Output isn't correct |
9 | Correct | 1 ms | 384 KB | Output is correct |
10 | Incorrect | 1 ms | 384 KB | Output isn't correct |
11 | Correct | 1 ms | 384 KB | Output is correct |
12 | Incorrect | 2 ms | 384 KB | Output isn't correct |
13 | Correct | 2 ms | 384 KB | Output is correct |
14 | Incorrect | 2 ms | 384 KB | Output isn't correct |
15 | Correct | 2 ms | 384 KB | Output is correct |
16 | Incorrect | 3 ms | 384 KB | Output isn't correct |
17 | Incorrect | 3 ms | 384 KB | Output isn't correct |
18 | Incorrect | 4 ms | 384 KB | Output isn't correct |
19 | Incorrect | 8 ms | 384 KB | Output isn't correct |
20 | Incorrect | 4 ms | 384 KB | Output isn't correct |