# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
853945 | tue147 | Garage (IOI09_garage) | C++14 | 2 ms | 476 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
# include <bits/stdc++.h>
using namespace std;
int n,m;
unsigned long long sum = 0;
int main(){
ios_base::sync_with_stdio;
cin.tie(0);
cin >> n >> m;
int r[n];
int w[m];
set<int> s;
unordered_map<int, int> store;
queue<int> q;
int temp;
for (int i=0; i< n; i++){
cin >> r[i];
s.insert(i);
}
for (int i=0; i< m; i++){
cin >> w[i];
}
for (int i=0; i< 2*m; i++){
cin >> temp;
if (temp > 0){
if (!s.empty()){
set<int>::iterator ptr = s.begin();
sum += r[*ptr] * w[temp-1];
store[temp] = *ptr;
s.erase(ptr);
}
else{
q.push(temp);
}
}
else{
temp = -temp;
int place = store[temp];
s.insert(place);
store.erase(temp);
}
while (!q.empty() && !s.empty()){
temp = q.front();
q.pop();
set<int>::iterator ptr = s.begin();
sum += r[*ptr] * w[temp-1];
store[temp] = *ptr;
s.erase(ptr);
}
}
cout << sum;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |