# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1016142 | socpite | Garage (IOI09_garage) | C++14 | 1 ms | 760 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;
const int maxn = 2005;
int n, m;
int id[maxn], R[maxn], W[maxn];
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n >> m;
priority_queue<int, vector<int>, greater<int>> pq;
for(int i = 1; i <= n; i++){
cin >> R[i];
pq.push(i);
}
queue<int> q;
int ans = 0;
for(int i = 1; i <= m; i++)cin >> W[i];
for(int i = 1; i <= 2*m; i++){
int x;
cin >> x;
if(x > 0)q.push(x);
else pq.push(id[-x]);
while(!q.empty() && !pq.empty()){
id[q.front()] = pq.top();
ans += W[q.front()]*R[pq.top()];
pq.pop();
q.pop();
}
}
cout << ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |