# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
733927 | vjudge1 | Garage (IOI09_garage) | C++98 | 3 ms | 340 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;
int main()
{
unsigned long long s=0;
int n,m,k=0,p=0,q=0;
cin>>n>>m;
int a[n][2],c[m], l[m*2],w[m];
for(int i=0; i<n; i++)
{
cin>>a[i][0]; a[i][1]=0;
}
for(int j=0; j<m; j++)
cin>>c[j];
int j=0;
for(int i=0; i<m*2; i++)
cin>>l[i];
for(int i=0; i<m*2; i++)
{
if(l[i]>0)
{
if(k>=n)
{
w[p]=l[i]; p++;
}
else{
for(int j=0; j<n; j++)
{
if(a[j][1]==0) {
a[j][1]=l[i]; s+=c[l[i]-1]*a[j][0]; k++; break;
}
}
}
}
else {
int x=abs(l[i]);
for(int j=0; j<n; j++)
{
if(a[j][1]==x) {
if(p>q) {
a[j][1]=w[q]; s+=a[j][0]*c[w[q]-1]; q++;
}
else {
a[j][1]=0; k--;} break;
}
}
}
}
cout<<s;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |