# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
994607 | ducksaysquack | Garage (IOI09_garage) | C++98 | 1 ms | 348 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>
#define int long long
using namespace std;
signed main() {
ios::sync_with_stdio(0); cin.tie(0);
int n, k; cin >> n >> k; vector<int> a(n), b(k), c(k);
for(int i=0;i<n;i++) cin >> a[i]; for(int i=0;i<k;i++) cin >> b[i];
set<int> s; queue<int> q; int ans = 0;
for(int i=0;i<n;i++) s.insert(i);
for(int i=0;i<2*k;i++) {
int x; cin >> x; if(x<0) s.insert(c[-x-1]); else q.push(x-1);
while(!s.empty()&&!q.empty()) {
int y = q.front(); ans += a[*s.begin()]*b[y], c[y]=*s.begin();
s.erase(s.begin()); q.pop();
}
}
cout << ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |