# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
342309 | VodkaInTheJar | Sažetak (COCI17_sazetak) | C++14 | 306 ms | 10896 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>
#pragma GCC optimize("O3")
#define endl '\n'
using namespace std;
const int maxn = 5e6 + 3;
const int maxm = 13;
int n, m;
int k[maxm];
void read()
{
cin >> n >> m;
for (int i = 1; i <= m; i++)
cin >> k[i];
}
bool dp[maxn];
void solve()
{
dp[0] = true;
for (int i = 1; i < n; i++)
for (int j = 1; j <= m; j++)
if (k[j] <= i && dp[i-k[j]] && i % k[j] == 0)
{
dp[i] = true;
break;
}
dp[n] = true;
int ans = 0;
for (int i = 0; i <= n-1; i++)
if (dp[i] && dp[i+1])
ans++;
cout << ans << endl;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
read();
solve();
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |