# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
155733 | Flying_dragon_02 | Brunhilda’s Birthday (BOI13_brunhilda) | C++14 | 1088 ms | 149080 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
typedef pair<int, int> ii;
const int mod = 1e9 + 7;
const int inf = 1e9;
int add(int x, int y) {
return (1ll * x + 1ll * y) % mod;
}
int del(int x, int y) {
return ((1ll * x - 1ll * y) % mod + mod) % mod;
}
int mul(int x, int y) {
return (1ll * x * 1ll * y) % mod;
}
const int N = 1e7 + 5;
int dp[N], p[N];
int bit[2 * N];
void update(int x, int val) {
while(x > 0) {
bit[x] = min(bit[x], val);
x -= x & (-x);
}
}
int get(int x) {
if(x == 0) return 0;
int val = inf;
while(x < N) {
val = min(val, bit[x]);
x += x & (-x);
}
return val;
}
int m, q;
int main() {
scanf("%d%d", &m, &q);
for(int i = 0; i < N; i++)
p[i] = 0;
for(int i = 1; i <= N - 5; i++)
bit[i] = inf;
for(int i = 1; i <= m; i++) {
int x;
scanf("%d", &x);
for(int l = 0; l < N; l++) {
if(x * l >= N) break;
p[x * l] = max(p[x * l], x);
}
}
for(int i = 0; i <= N - 5; i++) {
dp[i] = get(i);
if(!p[i]) continue;
update(i + p[i] - 1, dp[i] + 1);
}
for(int i = 1; i <= q; i++) {
int x;
scanf("%d", &x);
if(dp[x] == inf)
printf("oo\n");
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... |