# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
561669 | Trisanu_Das | Garage (IOI09_garage) | C++17 | 2 ms | 468 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;
int main(){
int n, m; cin >> n >> m;
int rates[n]; for(int i = 0; i < n; i++) cin >> rates[i];
int weights[m]; for(int i = 0; i < m; i++) cin >> weights[i];
vector<bool> status(n, true);
vector<int> in(n, -1);
int empty = 0, ans = 0;
for(int i = 0; i < 2 * m; i++){
int x; cin >> x;
if(x > 0){
ans += rates[empty] * weights[x - 1]; status[empty] = false; in[x - 1] = empty;
for(int i = 0; i < n; i++){
if(status[i]) {empty = i; break;}
}
}else{
status[in[abs(x) - 1]] = true; empty = min(empty, in[abs(x - 1)]);
}
}
cout << ans << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |