# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
57501 |
2018-07-15T07:58:38 Z |
Bodo171 |
Garage (IOI09_garage) |
C++14 |
|
7 ms |
1096 KB |
#include <iostream>
#include <fstream>
using namespace std;
const int nmax=2005;
int r[nmax],w[nmax],loc[nmax],lib[nmax],q[nmax];
int n,m,i,j,ans,ind,p,u,x;
int main()
{
//freopen("data.in","r",stdin);
cin>>n>>m;
for(i=1;i<=n;i++)
{
cin>>r[i];
lib[i]=1;
}
for(i=1;i<=m;i++)
{
cin>>w[i];
}
p=1;
for(i=1;i<=2*m;i++)
{
cin>>x;
if(x>0)
{
ind=1;
while(ind<=n&&(!lib[ind])) ind++;
if(ind==n+1) q[++u]=x;
else lib[ind]=0,ans+=r[ind]*w[x],loc[x]=ind;
}
else
{
x*=(-1);
lib[loc[x]]=1;
if(p<=u)
{
loc[q[p]]=loc[x];
lib[loc[x]]=1;
ans+=r[loc[x]]*w[q[p]];
p++;
}
}
}
cout<<ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
484 KB |
Output is correct |
3 |
Correct |
3 ms |
596 KB |
Output is correct |
4 |
Correct |
4 ms |
696 KB |
Output is correct |
5 |
Correct |
3 ms |
840 KB |
Output is correct |
6 |
Correct |
3 ms |
840 KB |
Output is correct |
7 |
Correct |
2 ms |
860 KB |
Output is correct |
8 |
Incorrect |
3 ms |
864 KB |
Output isn't correct |
9 |
Correct |
2 ms |
984 KB |
Output is correct |
10 |
Correct |
3 ms |
984 KB |
Output is correct |
11 |
Correct |
3 ms |
984 KB |
Output is correct |
12 |
Incorrect |
3 ms |
984 KB |
Output isn't correct |
13 |
Correct |
4 ms |
984 KB |
Output is correct |
14 |
Incorrect |
3 ms |
1060 KB |
Output isn't correct |
15 |
Correct |
4 ms |
1060 KB |
Output is correct |
16 |
Incorrect |
5 ms |
1060 KB |
Output isn't correct |
17 |
Incorrect |
4 ms |
1060 KB |
Output isn't correct |
18 |
Incorrect |
5 ms |
1060 KB |
Output isn't correct |
19 |
Correct |
6 ms |
1068 KB |
Output is correct |
20 |
Incorrect |
7 ms |
1096 KB |
Output isn't correct |