# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
630584 | lucri | Garage (IOI09_garage) | C++17 | 3 ms | 340 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |