# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
160514 | tushar_2658 | Brunhilda’s Birthday (BOI13_brunhilda) | C++14 | 1086 ms | 2248 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;
const int maxn = 100005;
int a[maxn], dp[maxn], n, m;
void solve(int x){
for(int i = 0; i < maxn; i++){
dp[i] = 1e8;
}
dp[0] = 0;
for(int i = 1; i <= x; i++){
for(int j = 1; j <= n; j++){
if(i - (i % a[j]) >= 0){
dp[i] = min(dp[i], 1 + dp[i - (i % a[j])]);
}
}
}
}
int main(int argc, char const *argv[])
{
// freopen("in.txt", "r", stdin);
scanf("%d %d", &n, &m);
for(int i = 1; i <= n; i++){
scanf("%d", &a[i]);
}
int x;
scanf("%d", &x);
solve(x);
dp[x] >= 1e8 ? printf("oo\n") : printf("%d\n", dp[x]);
return 0;
}
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... |