# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
591971 | starchan | Garage (IOI09_garage) | C++17 | 1092 ms | 432 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 int long long
#define in pair<int, int>
#define f first
#define s second
#define pb push_back
#define pob pop_back
#define INF (int)1e17
#define MX (int)3e5+5
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL)
signed main()
{
fast();
int n, m;
cin >> n >> m;
vector<int> r(n+1);
set<int> empty;
for(int i = 1; i <= n; i++)
{
cin >> r[i];
empty.insert(i);
}
vector<int> which(m+1);
vector<int> w(m+1);
for(int i = 1; i <= m; i++)
cin >> w[i];
int t = 2*m;
int ans = 0;
while(t--)
{
int x;
cin >> x;
int u = abs(x);
if(x > 0)
{
int k = *empty.begin();
which[u] = k;
empty.erase(empty.begin());
ans+=(w[u]*r[k]);
//cout << "Added " << w[u] << "*" << r[k] << " = " << w[u]*r[k] << endl;
}
else
empty.insert(which[u]);
}
cout << ans;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |