# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
283012 | shrek12357 | Garage (IOI09_garage) | C++14 | 4 ms | 384 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |