Submission #342309

# Submission time Handle Problem Language Result Execution time Memory
342309 2021-01-01T20:17:07 Z VodkaInTheJar Sažetak (COCI17_sazetak) C++14
64 / 160
306 ms 10896 KB
#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
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 54 ms 4460 KB Output is correct
4 Correct 94 ms 5100 KB Output is correct
5 Runtime error 53 ms 10860 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 57 ms 10860 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 71 ms 10860 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 133 ms 10860 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 306 ms 10896 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 62 ms 10860 KB Execution killed with signal 11 (could be triggered by violating memory limits)