# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
235317 |
2020-05-27T19:37:33 Z |
Pbezz |
Garage (IOI09_garage) |
C++14 |
|
7 ms |
384 KB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define INF 10000000
#define MAXN 100005
typedef pair<int, int> pii;
int main(){
ll int n,m,k,i,j,ans=0;
cin>>n>>m;
vector<ll int>cost(n);
vector<ll int>weight(m);
for(i=0;i<n;i++){
cin>>cost[i];
}
for(i=0;i<m;i++){
cin>>weight[i];
}
queue<ll int>q;
int location[m];//localização do carro i
int occupied[n];//que carro está em i
memset(location, -1, sizeof(location) );
memset(occupied, -1, sizeof(occupied) );
for(j=0;j<2*m;j++){
cin>>k;
if(k>0){k--;
q.push(k);
}else{k++;
occupied[location[-k]]=-1;
location[-k]=-1;
}
i=0;
while(!q.empty() && i<n){
while(i<n && occupied[i]!=-1)i++;
if(i==n)continue;
k=q.front(); q.pop();
occupied[i]=k;
location[k]=i;
ans+=weight[k]*cost[i];
}
//cout<<k<<" "<<ans<<endl;
}
cout<<ans<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
256 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
256 KB |
Output is correct |
4 |
Correct |
4 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
256 KB |
Output is correct |
7 |
Correct |
4 ms |
256 KB |
Output is correct |
8 |
Correct |
4 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
256 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
256 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
5 ms |
384 KB |
Output is correct |
15 |
Correct |
5 ms |
384 KB |
Output is correct |
16 |
Correct |
6 ms |
384 KB |
Output is correct |
17 |
Correct |
6 ms |
384 KB |
Output is correct |
18 |
Correct |
7 ms |
384 KB |
Output is correct |
19 |
Correct |
7 ms |
384 KB |
Output is correct |
20 |
Correct |
7 ms |
384 KB |
Output is correct |