# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
956417 | emad234 | Garage (IOI09_garage) | C++17 | 2 ms | 2648 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define pii pair<ll, ll>
const ll mod = 1e9 + 7;
const ll mxN = 1e5 + 5;
using namespace std;
ll val[mxN];
ll w[mxN];
ll pk[mxN];
int main(){
int n,m;
cin >>n>>m;
priority_queue<int,vector<int>,greater<int>>q;
for(int i = 1;i <= n;i++){
cin >>val[i];
q.push(i);
}
queue<int>car;
ll ans = 0;
for(int i = 1;i <= m;i++) cin >>w[i];
for(int i = 0;i < m * 2;i++){
int x;
cin >>x;
if(x > 0){
if(q.size()){
ans += val[q.top()] * w[x];
pk[x] = q.top();
q.pop();
}else{
car.push(x);
}
}else{
x *= -1;
if(car.size()){
ans += w[car.front()] * val[pk[x]];
pk[car.front()] = pk[x];
car.pop();
}else{
q.push(pk[x]);
}
}
}
cout<<ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |