# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1031674 |
2024-07-23T03:42:37 Z |
ezzzay |
Garage (IOI09_garage) |
C++14 |
|
1 ms |
444 KB |
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define int long long
const int N=3e5+5;
int pr[N];
int w[N];
int pos[N];
int arr[N];
signed main(){
int n,m;
cin>>n>>m;
for(int i=1;i<=n;i++){
cin>>pr[i];
}
for(int i=1;i<=m;i++){
cin>>w[i];
}
set<int>st,ts;
for(int i=1;i<=n;i++){
st.insert(i);
}
queue<int>q;
int ans=0;
for(int i=0;i<2*m;i++){
int h;
cin>>h;
if(h>0){
q.push(h);
}
else{
h*=-1;
st.insert(pos[h]);
pos[h]=0;
}
while(!q.empty() and st.size()>0){
int h=q.front();
q.pop();
int x=*st.begin();
st.erase(st.begin());
ans+= w[h]*pr[x];
pos[h]=x;
}
}
cout<<ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
444 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
432 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
444 KB |
Output is correct |