# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1016142 | socpite | Garage (IOI09_garage) | C++14 | 1 ms | 760 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2005;
int n, m;
int id[maxn], R[maxn], W[maxn];
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n >> m;
priority_queue<int, vector<int>, greater<int>> pq;
for(int i = 1; i <= n; i++){
cin >> R[i];
pq.push(i);
}
queue<int> q;
int ans = 0;
for(int i = 1; i <= m; i++)cin >> W[i];
for(int i = 1; i <= 2*m; i++){
int x;
cin >> x;
if(x > 0)q.push(x);
else pq.push(id[-x]);
while(!q.empty() && !pq.empty()){
id[q.front()] = pq.top();
ans += W[q.front()]*R[pq.top()];
pq.pop();
q.pop();
}
}
cout << ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |