# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
467991 | starplat | Garage (IOI09_garage) | C++14 | 2 ms | 332 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int m,n,ad;
long long r[105],w[2005],p,tmp,check;
bool a[105];
int aa[105];
queue<int> wa;
int main()
{
cin>>n>>m;
p=0;check=0;
for (int i=1;i<=n;i++){
scanf("%lld",&r[i]);
a[i]=true;
aa[i]=0;
}
for (int i=1;i<=m;i++) scanf("%lld",&w[i]);
for (int i=0;i<2*m;i++){
scanf("%d",&ad);
if (ad>0) {
for (int j=1;j<=n;j++){
if (a[j]==true){
a[j]=false;
aa[j]=ad;
p+=r[j]*w[ad];
break;
}
else check++;
}
if (check==n) wa.push(ad);
check=0;
}
else if (ad<0){
for (int j=1;j<=n;j++){
if (aa[j]==ad*-1){
a[j]=true;
aa[j]=0;
}
}
if (wa.empty()) continue;
else {
for (int j=1;j<=n;j++){
if (a[j]==true){
tmp=wa.front();
wa.pop();
a[j]=false;
aa[j]=tmp;
p+=r[j]*w[tmp];
break;
}
}
}
}
}
cout<<p<<"\n";
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |