# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
252026 |
2020-07-23T18:52:01 Z |
ScarletS |
Garage (IOI09_garage) |
C++17 |
|
2 ms |
384 KB |
#include <bits/stdc++.h>
#define ll long long
#define sz(x) (int)(x).size()
using namespace std;
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0);
int n,m,x;
ll ans=0;
cin>>n>>m;
priority_queue<int,vector<int>,greater<int>> q;
deque<int> wait;
int r[n];
int w[m+1];
int a[m+1];
for (int i=0;i<n;++i)
{
cin>>r[i];
q.push(i);
}
for (int i=1;i<=m;++i)
cin>>w[i];
for (int i=0;i<2*m;++i)
{
cin>>x;
if (x<0)
q.push(a[-x]);
else
wait.push_back(x);
if (sz(q)&&sz(wait))
{
x=wait.front();
wait.pop_front();
ans+=r[q.top()]*w[x];
a[x]=q.top();
q.pop();
}
}
cout<<ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
0 ms |
384 KB |
Output is correct |
7 |
Correct |
0 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
384 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
1 ms |
384 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
1 ms |
384 KB |
Output is correct |
17 |
Correct |
2 ms |
384 KB |
Output is correct |
18 |
Correct |
1 ms |
384 KB |
Output is correct |
19 |
Correct |
1 ms |
384 KB |
Output is correct |
20 |
Correct |
1 ms |
384 KB |
Output is correct |