# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
303050 | dolijan | Garage (IOI09_garage) | C++14 | 4 ms | 384 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 main()
{
long long n,m;
cin>>n>>m;
long long konstanta[n];
for(long long i=0;i<n;i++) cin>>konstanta[i];
long long tezina[m];
for(long long i=0;i<m;i++) cin>>tezina[i];
priority_queue<long long> pq;
for(long long i=0;i<n;i++) pq.push(-1*i);
long long kolko=0;
long long mesto[m];
queue<long long> q;
for(long long i=0;i<2*m;i++)
{
long long t;
cin>>t;
if(t<0)
{
t++;
pq.push(-1*mesto[-1*t]);
}
else
{
t--;
q.push(t);
}
if(!pq.empty() && !q.empty())
{
//cout<<konstanta[q.front()]<<" "<<tezina[pq.top()*(-1)]<<endl;
kolko+=tezina[q.front()]*konstanta[-1*(pq.top())];
mesto[q.front()]=-1*pq.top();
//cout<<"Ubacio "<<q.front()<<" na mesto "<<-1*pq.top()<<endl;
q.pop(); pq.pop();
}
}
cout<<kolko<<endl;
//system("PAUSE");
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |