Submission #156856

#TimeUsernameProblemLanguageResultExecution timeMemory
156856sochoGarage (IOI09_garage)C++14
5 / 100
3 ms504 KiB
#include "bits/stdc++.h" using namespace std; int main() { int n, m; cin >> n >> m; int occ[n]; memset(occ, 0, sizeof occ); int coe[n]; for (int i=0; i<n; i++) { cin >> coe[i]; } int where[n]; for (int i=0; i<n; i++) { where[i] = -1; } int wgt[m]; for (int i=0; i<m; i++) { cin >> wgt[i]; } int sm = 0; queue<int> wait; for (int i=0; i<2*m; i++) { int nxt; cin >> nxt; bool inc = true; if (nxt < 0) { inc = false; nxt = -nxt; } nxt--; if (inc) { wait.push(nxt); } else { int at = where[nxt]; occ[at] = false; } for (int j=0; j<n && !wait.empty(); j++) { if (!occ[j]) { occ[j] = true; int c = wait.front(); wait.pop(); sm += wgt[c] * coe[j]; where[c] = j; } } } cout << sm << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...