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