Submission #163961

#TimeUsernameProblemLanguageResultExecution timeMemory
163961luciocfBrunhilda’s Birthday (BOI13_brunhilda)C++14
20 / 100
663 ms1016 KiB
#include <bits/stdc++.h>

using namespace std;

const int maxn = 1e4+10;

int a[maxn];

int dp[maxn];

int main(void)
{
	int n, q;
	scanf("%d %d", &n, &q);

	for (int i = 1; i <= n; i++)
		scanf("%d", &a[i]);

	sort(a+1, a+n+1);

	for (int i = 1; i < maxn; i++)
		dp[i] = 1e9+10;

	for (int i = 1; i < maxn; i++)
		for (int j = n; j >= 1; j--)
			dp[i] = min(dp[i], 1+dp[i-(i%a[j])]);

	for (int i = 1; i <= q; i++)
	{
		int x;
		scanf("%d", &x);

		if (dp[x] != 1e9+10) printf("%d\n", dp[x]);
		else printf("oo\n");
	}
}

Compilation message (stderr)

brunhilda.cpp: In function 'int main()':
brunhilda.cpp:14:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n, &q);
  ~~~~~^~~~~~~~~~~~~~~~~
brunhilda.cpp:17:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &a[i]);
   ~~~~~^~~~~~~~~~~~~
brunhilda.cpp:31:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &x);
   ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...