Submission #292004

#TimeUsernameProblemLanguageResultExecution timeMemory
292004NicolaAbusaad2014Garage (IOI09_garage)C++14
100 / 100
2 ms512 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long n,m,x,ans=0; cin>>n>>m; long arr[n],weight[m],used[m]= {}; bool N_A[n]= {}; for(long i=0; i<n; i++) { cin>>arr[i]; } for(long i=0; i<m; i++) { cin>>weight[i]; } queue<long>q; for(long i=0; i<2*m; i++) { cin>>x; if(x>0) { q.push(x); } else { N_A[used[-x-1]]=false; } if(!q.empty()) { for(long j=0; j<n; j++) { if(!N_A[j]) { N_A[j]=true; x=q.front(); used[x-1]=j; ans+=(weight[x-1]*arr[j]); q.pop(); break; } } } } cout<<ans<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...