# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
209934 | dantoh000 | Brunhilda’s Birthday (BOI13_brunhilda) | C++14 | 19 ms | 1276 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000007;
const int MAXN = 10;
int a[MAXN];
int ans[MAXN];
int main(){
int n,q;
scanf("%d%d",&n,&q);
for (int i = 0; i < n; i++){
int k;
scanf("%d",&k);
for (int j = k-1; j < MAXN; j+=k){
a[j] = k-1;
}
}
for (int i = MAXN-2; i >= 0; i--){
a[i] = max(a[i],a[i+1]-1);
}
fill(ans,ans+MAXN,INF);
ans[1] = 1;
ans[0] = 0;
for (int i = 2; i < MAXN; i++){
if (a[i] == 0) ans[i] = INF;
else ans[i] = min(ans[i],ans[i-a[i]]+1);
}
for (int i = 0; i < q; i++){
int x;
scanf("%d",&x);
if (ans[x] == INF) printf("oo\n");
else printf("%d\n",ans[x]);
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |