# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
74696 | kjain_1810 | Brunhilda’s Birthday (BOI13_brunhilda) | C++17 | 342 ms | 41296 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define ind(n) scanf("%d", &n)
#define ind2(n, m) scanf("%d%d", &n, &m)
#define ind3(n, m, k) scanf("%d%d%d", &n, &m, &k)
#define inlld(n) scanf("%lld", &n)
#define inlld2(n, m) scanf("%lld%lld", &n, &m)
#define inlld3(n, m, k) scanf("%lld%lld%lld", &n, &m, &k)
using namespace std;
const int N=1e7+5;
const int MOD=1e9+7;
typedef long long ll;
typedef long double ld;
int n, q;
int arr[N], dp[N];
int solve(int i)
{
if(i==0)
return 0;
if(dp[i]!=-1)
return dp[i];
int ans=-1e8, best=0;
// if(q==1)
// {
// for(int a=n; a>=1; a--)
// {
// if(i%arr[a]==0)
// continue;
// if(i%arr[a]>ans)
// {
// ans=i%arr[a];
// best=a;
// }
// }
// }
// else
// {
for(int a=n; a>=max(1, n-500); a--)
{
if(i%arr[a]==0)
continue;
if(i%arr[a]>ans)
{
ans=i%arr[a];
best=a;
}
}
// }
if(best)
return dp[i]=solve(i-ans)+1;
else
return dp[i]=2e8;
}
signed main()
{
ind2(n, q);
for(int a=1; a<=n; a++)
ind(arr[a]);
memset(dp, -1, sizeof(dp));
while(q--)
{
int x;
ind(x);
int ans=solve(x);
if(ans<2e8)
printf("%d\n", ans);
else
printf("oo\n");
}
return 0;
}
컴파일 시 표준 에러 (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... |