# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
650908 |
2022-10-16T03:46:20 Z |
rewer |
Garage (IOI09_garage) |
C++14 |
|
6 ms |
340 KB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n,m,cnt=0;
int r[60000];
int kg[60000];
int ar[60000];
bool b[60000];
deque<int> dq;
int x[60000];
map<int,int> mp;
signed main(){
cin>>n>>m;
for(int i=1;i<=n;i++){
cin>>r[i];
mp[r[i]]=0;
}
for(int i=1;i<=m;i++){
cin>>kg[i];
}
// sort(r+1,r+1+n);
for(int i=1;i<=2*m;i++){
cin>>x[i];
bool nospace=true;
if(x[i]>0){
for(int j=1;j<=n;j++){
if(!b[j]){
nospace=false;
mp[r[j]]=x[i];
b[j]=true;
cnt=cnt+kg[x[i]]*r[j];
break;
}
}
if(nospace)dq.push_back(x[i]);
}
else if(x[i]<0){
x[i]=-x[i];
for(int j=1;j<=n;j++){
if(mp[r[j]]==x[i]){
mp[r[j]]=0;
b[j]=false;
if(!dq.empty()){
mp[r[j]]=dq[0];
b[j]=true;
cnt=cnt+kg[dq[0]]*r[j];
dq.pop_front();
}
}
}
}
}
cout<<cnt<<"\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
316 KB |
Output is correct |
5 |
Correct |
1 ms |
312 KB |
Output is correct |
6 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
9 |
Incorrect |
1 ms |
324 KB |
Output isn't correct |
10 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
11 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
12 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
13 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
14 |
Incorrect |
2 ms |
320 KB |
Output isn't correct |
15 |
Incorrect |
2 ms |
324 KB |
Output isn't correct |
16 |
Incorrect |
3 ms |
340 KB |
Output isn't correct |
17 |
Incorrect |
3 ms |
340 KB |
Output isn't correct |
18 |
Incorrect |
4 ms |
340 KB |
Output isn't correct |
19 |
Incorrect |
6 ms |
340 KB |
Output isn't correct |
20 |
Incorrect |
5 ms |
340 KB |
Output isn't correct |