Submission #630584

#TimeUsernameProblemLanguageResultExecution timeMemory
630584lucriGarage (IOI09_garage)C++17
100 / 100
3 ms340 KiB
#include <bits/stdc++.h> using namespace std; int n,m,r[110],g[2010],p[2010],x,ans; priority_queue<int>a; queue<int>b; int main() { cin>>n>>m; for(int i=1;i<=n;++i) { a.push(-i); cin>>r[i]; } for(int i=1;i<=m;++i) { cin>>g[i]; } m*=2; for(int i=1;i<=m;++i) { cin>>x; if(x<0) a.push(-p[-x]); else { b.push(x); } if(!b.empty()&&!a.empty()) { int z=-a.top(); a.pop(); int poz=b.front(); b.pop(); p[poz]=z; ans+=g[poz]*r[z]; } } cout<<ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...