# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
31868 | YoLo | Brunhilda’s Birthday (BOI13_brunhilda) | C++14 | 613 ms | 158656 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>
using namespace std;
int n, m, a[100009], j, num[20000009], nex, cur, t = 1, ans[20000009];
signed main()
{
scanf("%d%d",&n,&m);
for(int i = 1; i <= n; i++)
scanf("%d",&a[i]);
for(int i = 1; i <= n; i++)
{
j = 0;
while(j <= 10000000)
{
num[j] = max(num[j], j + a[i]);
j += a[i];
}
}
num[1] = num[0];
ans[1] = 1;
for(int i = 2; i <= 10000000; i++)
{
while(i >= num[cur] && cur < i)
{
cur ++;
}
if(cur == i)
break;
ans[i] = ans[cur] + 1;
}
while(m --)
{
int k;
cin >> k;
if(ans[k] > 0)
printf("%d\n",ans[k]);
else
printf("oo\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... |