# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
293949 | kshitij_sodani | Garage (IOI09_garage) | C++14 | 2 ms | 416 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 a first
#define b second
#define pb push_back
typedef long long llo;
int n,m;
int it[101];
int aa[2001];
int pp[2001];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
queue<int> ss;
cin>>n>>m;
set<int> cur;
for(int i=0;i<n;i++){
cur.insert(i);
}
for(int i=0;i<n;i++){
cin>>it[i];
}
for(int i=0;i<m;i++){
cin>>aa[i];
}
int ans=0;
for(int i=0;i<2*m;i++){
int ind;
cin>>ind;
if(ind<0){
cur.insert(pp[-ind]);
}
else{
ss.push(ind);
}
while(cur.size() and ss.size()){
int x=ss.front();
ss.pop();
int y=*(cur.begin());
cur.erase(y);
ans+=aa[x-1]*it[y];
pp[x]=y;
}
}
cout<<ans<<endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |