# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
684144 |
2023-01-20T14:44:08 Z |
Hacv16 |
Garage (IOI09_garage) |
C++17 |
|
1 ms |
340 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX = 2e5 + 15;
const int INF = 0x3f3f3f3f;
int n, m, rev, r[MAX], w[MAX], spot[MAX];
set<int> s;
queue<int> q;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n >> m;
for(int i = 1; i <= n; i++){
cin >> r[i];
s.insert(i);
}
for(int i = 1; i <= m; i++)
cin >> w[i];
for(int i = 1; i <= 2 * m; i++){
int car; cin >> car;
if(car < 0) s.insert(spot[-car]);
else q.push(car);
while(s.size()){
if(q.empty()) break;
int cur = q.front(); q.pop();
int curSpot = *(s.begin());
s.erase(s.begin());
spot[cur] = curSpot;
rev += w[cur] * r[curSpot];
}
}
cout << rev << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
340 KB |
Output is correct |
11 |
Correct |
0 ms |
340 KB |
Output is correct |
12 |
Correct |
0 ms |
340 KB |
Output is correct |
13 |
Correct |
0 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |