# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
283012 | shrek12357 | Garage (IOI09_garage) | C++14 | 4 ms | 384 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |