| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 651129 | rewer | Garage (IOI09_garage) | C++14 | 5 ms | 468 KiB | 
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 | 
|---|---|---|---|---|
| Fetching results... | ||||
