제출 #1196027

#제출 시각아이디문제언어결과실행 시간메모리
1196027edga1Garage (IOI09_garage)C++20
100 / 100
1 ms328 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define fi first #define se second #define pb push_back #define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define MOD 1000000007 int main() { fastIO; int n,m; cin>>n>>m; vector<int> r(n),w(m+1); for(int i=0; i<n; i++) cin>>r[i]; for(int i=1; i<=m; i++) cin>>w[i]; queue<int> ie; priority_queue<int, vector<int>, greater<int>> b; vector<int> g(m+1); int rez=0; for(int i=n-1; i>=0; i--) b.push(i); for(int i=0; i<m*2; i++){ int c; cin>>c; if(c>0){ ie.push(c); }else{ b.push(g[abs(c)]); } while(ie.size()>0 && b.size()>0){ rez+=r[b.top()]*w[ie.front()]; g[ie.front()]=b.top(); b.pop(); ie.pop(); } } cout<<rez; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...