# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
495532 | PiejanVDC | Garage (IOI09_garage) | C++17 | 3 ms | 332 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
signed main() {
int n,m; cin>>n>>m;
vector<int>s(n);
for(auto &z : s)
cin>>z;
vector<int>w(m);
for(auto &z : w)
cin>>z;
int64_t ans = 0LL;
vector<int>place(m);
priority_queue<int>pq;
for(int i = 0 ; i < n ; i++) pq.push(-i);
queue<int>line;
for(int i = 0 ; i < 2*m ; i++) {
while(!line.empty()) {
if(pq.empty()) break;
place[line.front()] = -pq.top();
ans += (s[-pq.top()]) * (w[line.front()]);
pq.pop();
line.pop();
}
int x; cin>>x;
if(x > 0) {
x--;
line.push(x);
} else {
x = -x;
x--;
pq.push(-(place[x]));
}
}
cout << ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |