# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
601053 | SlyGaleeb | Garage (IOI09_garage) | C++17 | 2 ms | 360 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ld long double
#define F first
#define S second
const ll N = 2e5 + 5;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,m,ans=0;
cin >> n >> m;
vector<int>v(n+1),w(m+1);
priority_queue<int,vector<int>,greater<int>>pq;
queue<int>q;
map<int,int>mp;
for (int i = 1; i <= n; ++i) {
cin >> v[i];
pq.push(i);
}
for (int i = 1; i <= m; ++i)
cin >> w[i];
for (int i = 0; i < 2*m; ++i) {
while (!q.empty() && !pq.empty()) {
ans += w[q.front()]*v[pq.top()];
mp[q.front()] = pq.top();
q.pop();
pq.pop();
}
int a;
cin >> a;
if (a>0) {
if (pq.empty())
q.push(a);
else {
ans += w[a]*v[pq.top()];
mp[a] = pq.top();
pq.pop();
}
}
else {
pq.push(mp[-a]);
mp.erase(-a);
}
}
cout << ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |