# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
717654 |
2023-04-02T10:18:19 Z |
ZeroCool |
Garage (IOI09_garage) |
C++14 |
|
2 ms |
340 KB |
#include <bits/stdc++.h>
#define ll long long
#define inf INT_MAX
#define endl '\n'
using namespace std;
const int mxn = 20;
void solve(){
int n, m;
long long result = 0;
cin>>n>>m;
vector<int>r(n + 1), w(m + 1);
for(int i = 1;i <= n;++i)cin>>r[i];
for(int i = 1;i <= m;++i)cin>>w[i];
vector<int>p(n + 1);
queue<int>q;
for(int i = 0;i < 2 * m;++i){
int c;
cin>>c;
bool park = false;
if(c > 0){
for(int j = 1;j <= n;++j){
if(!p[j]){
p[j] = c;
result += w[c] * r[j];
park = true;
break;
}
}
if(!park){
q.push(c);
}
}
else{
for(int j = 1;j <= n;++j){
if(-c == p[j]){
p[j] = 0;
break;
}
}
if(!q.empty()){
int cur = q.front();
q.pop();
for(int j = 1;j <= n;++j){
if(!p[j]){
p[j] = cur;
result += w[cur] * r[j];
break;
}
}
}
}
}
cout<<result<<endl;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t = 1;
//cin>>t;
while(t--) solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
316 KB |
Output is correct |
3 |
Correct |
1 ms |
320 KB |
Output is correct |
4 |
Correct |
1 ms |
316 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
320 KB |
Output is correct |
13 |
Correct |
1 ms |
324 KB |
Output is correct |
14 |
Correct |
1 ms |
328 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
2 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
328 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |