# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
384812 | ritul_kr_singh | Garage (IOI09_garage) | C++17 | 2 ms | 384 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;
#define int long long
#define sp << ' ' <<
#define nl << '\n'
signed main(){
cin.tie(0)->sync_with_stdio(0);
int n, m, c, ans = 0; cin >> n >> m;
int r[n]; for(int &i : r) cin >> i;
int w[m]; for(int &i : w) cin >> i;
int pos[m];
set<int> s;
queue<int> q;
for(int i=0; i<n; ++i) s.insert(i);
for(int i=0; i<m+m; ++i){
cin >> c;
if(c>0){
--c;
q.push(c);
}else{
s.insert(pos[-c-1]);
}
while(!s.empty() and !q.empty()){
c = q.front(); q.pop();
ans += r[pos[c] = *s.begin()] * w[c];
s.erase(s.begin());
}
}
cout << ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |