Submission #561669

#TimeUsernameProblemLanguageResultExecution timeMemory
561669Trisanu_DasGarage (IOI09_garage)C++17
5 / 100
2 ms468 KiB
#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 timeMemoryGrader output
Fetching results...