Submission #65307

#TimeUsernameProblemLanguageResultExecution timeMemory
65307zubecGarage (IOI09_garage)C++14
100 / 100
4 ms1016 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; int n, m, a[110], b[2100], ans; int curPos[2100]; int main(){ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin >> n >> m; set<int> av; for (int i = 1; i <= n; i++){ cin >> a[i]; av.insert(i); } for (int i = 1; i <= m; i++) cin >> b[i]; queue <int> q; for (int i = 1; i <= m+m; i++){ int x; cin >> x; if (x > 0){ q.push(x); } else { av.insert(curPos[-x]); } while(!av.empty() && !q.empty()){ int guy = q.front(); q.pop(); int pos = *av.begin(); av.erase(av.begin()); curPos[guy] = pos; ans += a[pos]*b[guy]; } } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...