| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 651129 | rewer | Garage (IOI09_garage) | C++14 | 5 ms | 468 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... | ||||
