# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
684139 | Hacv16 | Garage (IOI09_garage) | C++17 | 1 ms | 344 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX = 2e6 + 15;
const int INF = 0x3f3f3f3f;
ll n, m, rev, r[MAX], w[MAX], spot[MAX];
set<int> s;
queue<int> q;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n >> m;
for(int i = 1; i <= n; i++){
cin >> r[i];
s.insert(i);
}
for(int i = 1; i <= m; i++)
cin >> w[i];
for(int i = 1; i <= 2 * m; i++){
int car; cin >> car;
if(car < 0) car = -car;
if(spot[car] != 0){
s.insert(spot[car]);
if(q.size()){
int nx = q.front(); q.pop();
spot[nx] = spot[car];
rev += r[spot[nx]] * w[nx];
}else{
s.insert(spot[car]);
}
}else{
if(s.size()){
int curSpot = *s.begin();
s.erase(s.begin());
spot[car] = curSpot;
rev += r[spot[car]] * w[car];
}else{
q.push(car);
}
}
}
cout << rev << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |