# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
151331 | GioChkhaidze | Garage (IOI09_garage) | C++14 | 5 ms | 416 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
const int N=104;
const int M=2004;
long long n,m,Cars;
long long R[N],W[M],Id[M];
long long ANS;
bool F[N];
queue < int > q;
main () {
cin>>n>>m;
for (int i=1; i<=n; i++)
cin>>R[i];
for (int i=1; i<=m; i++)
cin>>W[i];
for (int i=1; i<=2*m; i++) {
int idx=0;
cin>>idx;
if (idx<0) idx=-idx,Cars--,F[Id[idx]]=0;
else q.push(idx);
while (q.size() && n>Cars) {
int ID=q.front();
q.pop();
for (int j=1; j<=n; j++)
if (!F[j]) {
Cars++,F[j]=1,Id[ID]=j;
ANS+=R[j]*W[ID];
break;
}
}
}
cout<<ANS<<endl;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |