# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1088668 | StefanSebez | Garage (IOI09_garage) | C++14 | 27 ms | 2116 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define ll long long
#define ld long double
int main(){
int n,m;scanf("%i%i",&n,&m);
int a[n+10];for(int i=1;i<=n;i++) scanf("%i",&a[i]);
int b[m+10];for(int i=1;i<=m;i++) scanf("%i",&b[i]);
int q=2*m;
queue<int>kju;
int res=0;
int broj[n+10]={0};
while(q--){
for(int i=1;i<=n;i++) printf("%i ",broj[i]);printf("\n");
int j;scanf("%i",&j);
if(j>0){
bool bul=false;
for(int i=1;i<=n;i++){
if(!broj[i]){
res+=a[i]*b[j];
broj[i]=j;
bul=true;
break;
}
}
if(!bul) kju.push(j);
}
else{
j=-j;
bool bul=false;
for(int i=1;i<=n;i++){
if(!broj[i]) bul=true;
if(broj[i]==j){
broj[i]=0;
}
}
if(!bul && kju.size()){
j=kju.front();kju.pop();
for(int i=1;i<=n;i++){
if(!broj[i]){
res+=a[i]*b[j];
broj[i]=j;
bul=true;
break;
}
}
}
}
}
printf("%i\n",res);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |