# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
73777 | TuGSGeReL | Garage (IOI09_garage) | C++14 | 5 ms | 960 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pub push_back
#define pob pop_back
#define ss second
#define ff first
#define ext exit(0)
using namespace std;
ll n,m,i,cst[101],w[2001],pos[2001],x,ans;
priority_queue<int>pq;
deque<int>v;
int main (){
cin>>n>>m;
for(i=1;i<=n;i++){
cin>>cst[i];
pq.push(-i);
}
for(i=1;i<=m;i++) cin>>w[i];
for(i=1;i<=2*m;i++){
cin>>x;
if(x>0){
if(v.size()) v.pub(x);
else {
if(pq.size()==0) v.pub(x);
else{
ll o=-pq.top();
pos[x]=o;
ans+=w[x]*cst[o];
pq.pop();
}
}
}
else{
pq.push(-pos[-x]);
if(v.size()){
ll o=-pq.top();
pos[v.front()]=o;
ans+=w[v.front()]*(cst[o]);
pq.pop();
v.pop_front();
}
}
}
cout<<ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |