| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 493678 | goodluck2020 | Brunhilda’s Birthday (BOI13_brunhilda) | C++14 | 160 ms | 636 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 task "brunhilda"
using namespace std;
const int N = 1e4 + 5;
int m, q, A[N];
namespace sub1
{
int dp[N];
void solve()
{
for(int i = 1; i <= 1e4; i++) dp[i] = 1e9;
for(int i = 1; i <= 1e4; i++)
for(int j = 1; j <= m; j++)
dp[i] = min(dp[i], dp[i - i % A[j]] + 1);
while(q--)
{
int n;
cin >> n;
if(dp[n] == 1e9) cout << "oo" << '\n';
else cout << dp[n] << '\n';
}
}
}
int main()
{
if(fopen(task ".inp","r"))
{
freopen(task ".inp","r",stdin);
freopen(task ".out","w",stdout);
}
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> m >> q;
for(int i = 1; i <= m; i++) cin >> A[i];
if(m <= 1e4 && q <= 1e4) sub1::solve();
}
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... | ||||
