# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
879051 | klee | Garage (IOI09_garage) | C++14 | 2 ms | 604 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;
vector<int> have(101), where(101);
int main()
{
int n,m;
cin >> n >> m;
vector<int> price(n+1), weight(m+1);
for(int i=1;i<=n;i++) cin >> price[i];
for(int i=1;i<=m;i++) cin >> weight[i];
int ans=0;
for(int i=0;i<2*m;i++)
{
int x;
cin >> x;
if(x>=0)
{
for(int j=1;j<=n;j++)
{
if(have[j] == 0)
{
have[j] = 1;
ans+= (price[j]*weight[x]);
// cout << j << 'a' << x << ' ' << price[j] << ' ' << weight[x] << ' ' << price[j]*weight[x] << ' ' << ans << ' ' << '\n';
where[x] = j;
break;
}
}
}
else
{
x = abs(x);
int a = where[x];
have[a] = 0;
}
}
cout << ans << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |