Submission #283012

#TimeUsernameProblemLanguageResultExecution timeMemory
283012shrek12357Garage (IOI09_garage)C++14
100 / 100
4 ms384 KiB
#include <iostream> #include <vector> #include <algorithm> #include <string> #include <map> #include <set> #include <climits> #include <cmath> #include <fstream> #include <queue> using namespace std; int main() { int n, m; cin >> n >> m; vector<int> parking; vector<int> weights; weights.push_back(0); int ans = 0; set<int> rem; parking.push_back(0); for (int i = 0; i < n; i++) { int temp; cin >> temp; parking.push_back(temp); rem.insert(i + 1); } for (int i = 0; i < m; i++) { int temp; cin >> temp; weights.push_back(temp); } map<int, int> pos; queue<int> toPlace; for (int i = 0; i < 2 * m; i++) { int temp; cin >> temp; if (temp < 0) { temp *= -1; rem.insert(pos[temp]); } else { toPlace.push(temp); } while (rem.size() > 0 && toPlace.size() > 0) { pos[toPlace.front()] = *rem.begin(); ans += weights[toPlace.front()] * parking[*rem.begin()]; rem.erase(rem.begin()); toPlace.pop(); } } cout << ans << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...