# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
138449 | baluteshih | Garage (IOI09_garage) | C++14 | 3 ms | 420 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>
#define pb push_back
#define jizz ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define ET cout << "\n"
#define F first
#define S second
#define MP make_pair
#define ALL(v) v.begin(),v.end()
#define MEM memset(i,j,sizeof i)
#define DB(a,s,e) {for(int i=s;i<e;++i) cout << a[i] << " ";ET;}
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int price[105],wei[2005],pl[2005];
bitset<105> used;
queue<int> q;
int main()
{jizz
int n,m,x,ans=0;
cin >> n >> m;
for(int i=1;i<=n;++i)
cin >> price[i];
for(int i=1;i<=m;++i)
cin >> wei[i];
for(int i=1;i<=2*m;++i)
{
cin >> x;
if(x<0)
{
used[pl[-x]]=0;
if(!q.empty())
pl[q.front()]=pl[-x],ans+=wei[q.front()]*price[pl[-x]],q.pop(),used[pl[-x]]=1;
}
else
if(used.count()==n) q.push(x);
else
{
for(int j=1;j<=n;++j)
if(!used[j])
{
pl[x]=j,ans+=wei[x]*price[j],used[j]=1;
break;
}
}
}
cout << ans << "\n";
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |