# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
310925 |
2020-10-08T14:26:27 Z |
Benmath |
Garage (IOI09_garage) |
C++14 |
|
4 ms |
384 KB |
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,m;
cin>>n>>m;
long long int a[n];
long long int b[m];
int d[n];
int vis[n];
for(int i=0;i<n;i++){
cin>>a[i];
d[i]=-1;
vis[i]=0;
}
for(int i=0;i<m;i++){
cin>>b[i];
}
long long int sum=0;
queue<int>q;
for(int i=0;i<2*m;i++){
int x;
cin>>x;
if(x>0){
int brojac=0;
for(int j=0;j<n;j++){
if(vis[j]==0){
brojac++;
sum=sum+a[j]*b[x-1];
vis[j]++;
d[x-1]=j;
break;
}
}
if(brojac==0){
q.push(x);
}
}else{
x=abs(x);
vis[d[x-1]]--;
d[x-1]=-1;
if(!q.empty()){
int l=q.front();
q.pop();
for(int j=0;j<n;j++){
if(vis[j]==0){
sum=sum+a[j]*b[l-1];
vis[j]++;
d[l-1]=j;
break;
}
}
}
}
}
cout<<sum;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
2 |
Incorrect |
0 ms |
256 KB |
Output isn't correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Incorrect |
0 ms |
256 KB |
Output isn't correct |
5 |
Incorrect |
0 ms |
256 KB |
Output isn't correct |
6 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
7 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
8 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
9 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
10 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
11 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
12 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
13 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
14 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
15 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
16 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
17 |
Incorrect |
3 ms |
256 KB |
Output isn't correct |
18 |
Incorrect |
3 ms |
384 KB |
Output isn't correct |
19 |
Incorrect |
3 ms |
384 KB |
Output isn't correct |
20 |
Incorrect |
4 ms |
384 KB |
Output isn't correct |