| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 989797 | aaaaaarroz | Garage (IOI09_garage) | C++17 | 2 ms | 436 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<int> rate(n);
for (int i = 0; i < n; i++) {
cin >> rate[i];
}
vector<int> weight(m);
for (int i = 0; i < m; i++) {
cin >> weight[i];
}
queue<int> cola;
vector<bool> ocupado(n, false);
map<int, int> espacio;
int ganancia = 0;
int q = 2 * m;
while (q--) {
int v;
cin >> v;
if (v >= 1) {
v--;
int peso = weight[v];
bool encontrado = false;
for (int i = 0; i < n; i++) {
if (!ocupado[i]) {
ocupado[i] = true;
espacio[v] = i;
ganancia += (rate[i] * peso);
encontrado = true;
break;
}
}
if (!encontrado) {
cola.push(v);
}
} else {
v = -v - 1;
int i = espacio[v];
ocupado[i] = false;
if (!cola.empty()) {
int nextCar = cola.front();
cola.pop();
int peso = weight[nextCar];
ocupado[i] = true;
espacio[nextCar] = i;
ganancia += (rate[i] * peso);
}
}
}
cout << ganancia << "\n";
return 0;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
