# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
535007 | devariaota | Garage (IOI09_garage) | C++17 | 3 ms | 332 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
typedef long long ll;
using namespace std;
ll n, m, ans;
ll car[2005], park[2005], rate[105];
queue<ll>q;
priority_queue<int, vector<int>, greater<int> >pq;
int main(){
cin >> n >> m;
for(int i = 1; i <= n; i++){
ll rates; cin >> rates;
pq.push(i);
rate[i] = rates;
}
for(int i = 1; i <= m; i++){
cin >> car[i];
}
for(int i = 1; i <= 2*m; i++){
ll f; cin >> f;
if(f > 0){
if(!pq.empty()){
ans += car[f]*rate[pq.top()];
park[f] = pq.top();
pq.pop();
}
else{
q.push(f);
}
}
else{
f*=-1;
pq.push(park[f]);
if(!q.empty()){
ll w = car[q.front()];
ans += w*rate[pq.top()];
park[q.front()] = pq.top();
pq.pop();
q.pop();
}
}
}
cout << ans << "\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |