# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
733884 | vjudge1 | Garage (IOI09_garage) | C++17 | 2 ms | 340 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
int ans, a[101], b[2001], n, m, x, vis[2001];
set<int> s;
set<int>::iterator it;
vector<int> v;
int main() {
cin >> n >> m;
for(int i = 1; i <= n; i++) {
cin >> a[i];
s.insert(i);
}
for(int i = 1; i <= m; i++) {
cin >> b[i];
}
for(int i = 1; i <= m * 2; i++) {
cin >> x;
if(x < 0) {
s.insert(vis[x * -1]);
if(v.size() != 0) {
it = s.begin();
vis[v[0]] = *it;
ans += a[*it] * b[v[0]];
s.erase(it);
v.erase(v.begin());
}
}
else {
v.push_back(x);
if(s.size() != 0){
it = s.begin();
vis[v[0]] = *it;
ans += a[*it] * b[v[0]];
// cout << a[*it] << ' ' << b[v[0]] << '\n';
s.erase(it);
v.erase(v.begin());
}
}
}
cout << ans;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |