# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
303050 |
2020-09-19T19:37:05 Z |
dolijan |
Garage (IOI09_garage) |
C++14 |
|
4 ms |
384 KB |
#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 |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
0 ms |
256 KB |
Output is correct |
5 |
Correct |
1 ms |
256 KB |
Output is correct |
6 |
Correct |
0 ms |
256 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
256 KB |
Output is correct |
9 |
Correct |
1 ms |
256 KB |
Output is correct |
10 |
Correct |
1 ms |
256 KB |
Output is correct |
11 |
Correct |
1 ms |
256 KB |
Output is correct |
12 |
Correct |
1 ms |
256 KB |
Output is correct |
13 |
Correct |
2 ms |
384 KB |
Output is correct |
14 |
Correct |
3 ms |
384 KB |
Output is correct |
15 |
Correct |
2 ms |
384 KB |
Output is correct |
16 |
Correct |
2 ms |
384 KB |
Output is correct |
17 |
Correct |
3 ms |
384 KB |
Output is correct |
18 |
Correct |
3 ms |
384 KB |
Output is correct |
19 |
Correct |
3 ms |
384 KB |
Output is correct |
20 |
Correct |
4 ms |
384 KB |
Output is correct |