# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
225960 | FieryPhoenix | Garage (IOI09_garage) | C++11 | 13 ms | 512 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;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;
#define INF 2001001001
#define MOD 1000000007
int N,M;
int R[101];
ll ans;
int occ[101];
int W[101];
int main()
{
//ios_base::sync_with_stdio(0);cin.tie(0);
//freopen (".in","r",stdin);
//freopen (".out","w",stdout);
cin>>N>>M;
for (int i=1;i<=N;i++)
cin>>R[i];
for (int i=1;i<=M;i++)
cin>>W[i];
queue<int>q;
for (int i=1;i<=M*2;i++){
int X; cin>>X;
if (X>0)
q.push(X);
else{
for (int j=1;j<=N;j++)
if (occ[j]==-X){
occ[j]=0;
break;
}
}
while (!q.empty()){
int spot=-1;
for (int j=1;j<=N;j++)
if (occ[j]==0){
spot=j;
break;
}
if (spot==-1) break;
occ[spot]=q.front();
ans+=W[q.front()]*R[spot];
q.pop();
}
}
cout<<ans<<endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |