| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 309472 | cig32 | Garage (IOI09_garage) | C++14 | 4 ms | 384 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
bool tiAs(bool available[], int N){
for(int i=0;i<N;i++){
if(available[i]==true){
return true;
}
}
return false;
}
int bS(bool available[], int N){
for(int i=0;i<N;i++){
if(available[i]==true){
return i;
}
}
}
int main(){
int N,M;
cin >> N >> M;
int r[N],w[M];
bool available[N];
int space[M];
for(int i=0;i<N;i++){
cin >> r[i];
available[i]=true;
}
for(int i=0;i<M;i++){
cin >> w[i];
}
int ans=0;
queue<int> waiting;
for(int i=0;i<2*M;i++){
int input;
cin >> input;
if(input>0){
if(tiAs(available,N)==true){
int t=bS(available,N);
available[t]=false;
space[input-1]=t;
int a=w[input-1]*r[t];
ans+=a;
}
else{
waiting.push(input);
}
}
else{
available[space[abs(input)-1]]=true;
if(waiting.size()!=0){
available[space[abs(input)-1]]=false;
space[waiting.front()-1]=space[abs(input)-1];
int a=w[waiting.front()-1]*r[space[abs(input)-1]];
waiting.pop();
ans+=a;
}
}
}
cout << ans;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
