# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
25867 | gs14004 | Brunhilda’s Birthday (BOI13_brunhilda) | C++11 | 463 ms | 80144 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int, int> pi;
const int mod = 1e9 + 7;
int n, q;
int nxt[10000005];
int dp[10000005];
int main(){
scanf("%d %d",&n,&q);
for(int i=1; i<=n; i++){
int x;
scanf("%d",&x);
for(int j=x; j-1<=10000000; j+=x){
nxt[j-1] = x-1;
}
nxt[10000000] = max(nxt[10000000], 10000000 % x);
}
for(int i=10000000; i; i--) nxt[i] = max(nxt[i], nxt[i+1] - 1);
for(int i=1; i<=10000000; i++){
if(dp[i - nxt[i]] == -1 || nxt[i] == 0) dp[i] = -1;
else dp[i] = dp[i - nxt[i]] + 1;
}
while(q--){
int x;
scanf("%d",&x);
if(dp[x] < 0) puts("oo");
else printf("%d\n", dp[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... |