제출 #31877

#제출 시각아이디문제언어결과실행 시간메모리
31877YoLoBrunhilda’s Birthday (BOI13_brunhilda)C++14
62.86 / 100
606 ms158656 KiB
#include<bits/stdc++.h>
using namespace std;
int n, m, a[100009], j, num[20000009], nex, cur, t = 1, ans[20000009];
signed main()
{
	scanf("%d %d",&n,&m);
	for(int i = 1; i <= n; i++)
		scanf("%d",&a[i]);
	for(int i = 1; i <= n; i++)
		for(int j = 0; j <= 10000000; j += a[i])
			num[j] = max(num[j], a[i]);
	for(int i = 1; i <= 10000000; i++)
	{
		while(i >= num[cur] + cur && cur < i)
			cur ++;
		if(cur == i)
			break;
		ans[i] = ans[cur] + 1;
	}
	for(int i = 0; i < m; i++)
	{
		int k;
		cin >> k;
		if(ans[k] > 0)
			printf("%d\n",ans[k]);
		else
			printf("oo\n");
	}
}

컴파일 시 표준 에러 (stderr) 메시지

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