Submission #651129

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