| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 267936 | hhh07 | Garage (IOI09_garage) | C++14 | 4 ms | 512 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <cstring>
using namespace std;
typedef pair<int, int> ii;
int main(){
int n, m;
cin >> n >> m;
int w[m], r[n];
priority_queue<int> rq;
for (int i = 0; i < n; i++){
cin >> r[i];
rq.push(-(i + 1));
}
for (int i = 0; i < m; i++)
cin >> w[i];
int x[2*m];
for (int i = 0; i < 2*m; i++)
cin >> x[i];
queue<int> q;
int car[m];
int val = 0;
for (int i = 0; i < 2*m; i++){
if (x[i] > 0)
q.push(x[i] - 1);
else
rq.push(-(car[-x[i] - 1] + 1));
while(!rq.empty()){
if (q.empty())
break;
int x = rq.top();
int y = q.front();
q.pop(); rq.pop();
val += w[y]*r[- x - 1];
//cout << w[y] << " " << r[- x - 1] << endl;
car[y] = - x - 1;
}
}
cout << val << endl;
return 0;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
