# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
57507 |
2018-07-15T08:00:28 Z |
Bodo171 |
Garage (IOI09_garage) |
C++14 |
|
6 ms |
664 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,ind,p,u,x;
long long ans;
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+=1LL*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+=1LL*r[loc[x]]*w[q[p]];
p++;
}
}
}
cout<<ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
3 ms |
484 KB |
Output is correct |
3 |
Correct |
2 ms |
484 KB |
Output is correct |
4 |
Correct |
2 ms |
604 KB |
Output is correct |
5 |
Correct |
3 ms |
664 KB |
Output is correct |
6 |
Correct |
2 ms |
664 KB |
Output is correct |
7 |
Correct |
2 ms |
664 KB |
Output is correct |
8 |
Incorrect |
4 ms |
664 KB |
Output isn't correct |
9 |
Correct |
2 ms |
664 KB |
Output is correct |
10 |
Correct |
3 ms |
664 KB |
Output is correct |
11 |
Correct |
2 ms |
664 KB |
Output is correct |
12 |
Incorrect |
2 ms |
664 KB |
Output isn't correct |
13 |
Correct |
4 ms |
664 KB |
Output is correct |
14 |
Incorrect |
5 ms |
664 KB |
Output isn't correct |
15 |
Correct |
4 ms |
664 KB |
Output is correct |
16 |
Incorrect |
5 ms |
664 KB |
Output isn't correct |
17 |
Incorrect |
5 ms |
664 KB |
Output isn't correct |
18 |
Incorrect |
5 ms |
664 KB |
Output isn't correct |
19 |
Correct |
4 ms |
664 KB |
Output is correct |
20 |
Incorrect |
6 ms |
664 KB |
Output isn't correct |