# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
733916 | vjudge1 | Garage (IOI09_garage) | C++17 | 2 ms | 468 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
int t, n, m, ans, i, z,j, x, r, p, s, y;
cin >> n >> m;
ll a[n + 2], b[m + 2], c[m + 2];
ans = 0;
priority_queue < ll , vector < ll > , greater< ll >> pq;
for ( i = 1; i <= n; i ++) {
cin >> a[i];
pq.push(i);
}
for ( i = 1; i <= m; i ++) {
cin >> b[i];
}
queue < ll > q;
for ( i = 1; i <= 2 * m; i ++) {
cin >> x;
if ( x < 0) {
r = -x;
pq.push(c[r]);
}
else {
if ( pq.empty()) {
q.push(x);
}
p = pq.top();
pq.pop();
c[x] = p;
ans += (a[p] * b[x]);
}
if ( !pq.empty() && !q.empty()) {
x = q.front();
q.pop();
p = pq.top();
pq.pop();
c[x] = p;
ans += (a[p] * b[x]);
}
}
cout << ans << endl;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |