Submission #220415

#TimeUsernameProblemLanguageResultExecution timeMemory
220415tatyamGarage (IOI09_garage)C++17
100 / 100
6 ms384 KiB
#include <bits/stdc++.h> using namespace std; #define rep(b) for(int i = 0; i < b; i++) #define each(i,a) for(auto&& i : a) #define all(a) begin(a), end(a) int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int n, m; cin >> n >> m; vector<int> r(n), w(m); each(i, r) cin >> i; each(i, w) cin >> i; int ans = 0; vector<int> park(m); priority_queue<int, vector<int>, greater<int>> space; queue<int> q; rep(n) space.push(i); rep(m * 2){ int a; cin >> a; if(a < 0){ if(q.size()){ int at = park[~a]; a = q.front(); q.pop(); park[a] = at; ans += r[at] * w[a]; } else space.push(park[~a]); } else{ a--; if(space.size()){ int at = space.top(); space.pop(); park[a] = at; ans += r[at] * w[a]; } else q.push(a); } } cout << ans << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...