# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1031674 | ezzzay | Garage (IOI09_garage) | C++14 | 1 ms | 444 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;
#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 |
---|---|---|---|---|
Fetching results... |