제출 #384812

#제출 시각아이디문제언어결과실행 시간메모리
384812ritul_kr_singhGarage (IOI09_garage)C++17
100 / 100
2 ms384 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define sp << ' ' << #define nl << '\n' signed main(){ cin.tie(0)->sync_with_stdio(0); int n, m, c, ans = 0; cin >> n >> m; int r[n]; for(int &i : r) cin >> i; int w[m]; for(int &i : w) cin >> i; int pos[m]; set<int> s; queue<int> q; for(int i=0; i<n; ++i) s.insert(i); for(int i=0; i<m+m; ++i){ cin >> c; if(c>0){ --c; q.push(c); }else{ s.insert(pos[-c-1]); } while(!s.empty() and !q.empty()){ c = q.front(); q.pop(); ans += r[pos[c] = *s.begin()] * w[c]; s.erase(s.begin()); } } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...