# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
30900 | Navick | Brunhilda’s Birthday (BOI13_brunhilda) | C++14 | 843 ms | 158268 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define F first
#define S second
#define pii pair<int, int>
#define pb push_back
using namespace std;
typedef long long ll;
typedef long double ld;
const int N = 1e7 + 10, INF = 1e9;
int dp[N], p[N], rm[2 * N];
int main(){
int m, q; scanf("%d %d", &m, &q);
for(int i=0; i<m; i++){
scanf("%d", p + i);
for(int k=p[i] - 1; k<2 * N; k+=p[i])
rm[k] = p[i] - 1;
}
for(int i=2*N-1; i>=1; i--)
rm[i] = max(rm[i], rm[i + 1] - 1);
for(int i=1; i<N; i++){
if(rm[i] == 0){
break;
}else{
dp[i] = dp[i - rm[i]] + 1;
}
}
for(int i=0; i<q; i++){
int n; scanf("%d", &n);
if(dp[n] == 0)
printf("oo\n");
else printf("%d\n", dp[n]);
}
}
Compilation message (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... |