# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
65307 | zubec | Garage (IOI09_garage) | C++14 | 4 ms | 1016 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;
typedef long long ll;
typedef long double ld;
int n, m, a[110], b[2100], ans;
int curPos[2100];
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin >> n >> m;
set<int> av;
for (int i = 1; i <= n; i++){
cin >> a[i];
av.insert(i);
}
for (int i = 1; i <= m; i++)
cin >> b[i];
queue <int> q;
for (int i = 1; i <= m+m; i++){
int x;
cin >> x;
if (x > 0){
q.push(x);
} else {
av.insert(curPos[-x]);
}
while(!av.empty() && !q.empty()){
int guy = q.front();
q.pop();
int pos = *av.begin();
av.erase(av.begin());
curPos[guy] = pos;
ans += a[pos]*b[guy];
}
}
cout << ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |