# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
53446 |
2018-06-30T04:41:47 Z |
노영훈(#1418) |
Garage (IOI09_garage) |
C++11 |
|
3 ms |
748 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MX=2010, inf=2e9;
int n, m, W[MX], R[MX];
int car[MX];
ll ans;
void put(int pos, int x){
ans+=R[pos]*W[x];
car[pos]=x;
}
int main(){
ios::sync_with_stdio(0); cin.tie(0);
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 _=1; _<=2*m; _++){
int x; cin>>x;
if(x>0){
int in=0;
for(int i=1; i<=n; i++){
if(car[i]==0){
in=i; break;
}
}
if(in==0) Q.push(x);
else put(in, x);
}
else{
x=-x;
for(int i=1; i<=n; i++){
if(car[i]==x){
car[i]=0;
if(!Q.empty()){
int v=Q.front(); Q.pop();
put(i,v);
}
break;
}
}
}
}
cout<<ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
464 KB |
Output is correct |
4 |
Correct |
2 ms |
468 KB |
Output is correct |
5 |
Correct |
2 ms |
548 KB |
Output is correct |
6 |
Correct |
2 ms |
560 KB |
Output is correct |
7 |
Correct |
2 ms |
664 KB |
Output is correct |
8 |
Correct |
2 ms |
664 KB |
Output is 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 |
Correct |
2 ms |
664 KB |
Output is correct |
13 |
Correct |
2 ms |
664 KB |
Output is correct |
14 |
Correct |
2 ms |
664 KB |
Output is correct |
15 |
Correct |
3 ms |
748 KB |
Output is correct |
16 |
Correct |
3 ms |
748 KB |
Output is correct |
17 |
Correct |
3 ms |
748 KB |
Output is correct |
18 |
Correct |
3 ms |
748 KB |
Output is correct |
19 |
Correct |
3 ms |
748 KB |
Output is correct |
20 |
Correct |
3 ms |
748 KB |
Output is correct |