# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
495532 | PiejanVDC | Garage (IOI09_garage) | C++17 | 3 ms | 332 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
signed main() {
int n,m; cin>>n>>m;
vector<int>s(n);
for(auto &z : s)
cin>>z;
vector<int>w(m);
for(auto &z : w)
cin>>z;
int64_t ans = 0LL;
vector<int>place(m);
priority_queue<int>pq;
for(int i = 0 ; i < n ; i++) pq.push(-i);
queue<int>line;
for(int i = 0 ; i < 2*m ; i++) {
while(!line.empty()) {
if(pq.empty()) break;
place[line.front()] = -pq.top();
ans += (s[-pq.top()]) * (w[line.front()]);
pq.pop();
line.pop();
}
int x; cin>>x;
if(x > 0) {
x--;
line.push(x);
} else {
x = -x;
x--;
pq.push(-(place[x]));
}
}
cout << ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |