Submission #31856

#TimeUsernameProblemLanguageResultExecution timeMemory
31856YoLoBrunhilda’s Birthday (BOI13_brunhilda)C++14
0 / 100
563 ms80532 KiB
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'
#define pi acos(-1)
#define pque priority_queue
typedef pair < int, int > ii;
typedef vector < int > vi;
typedef vector < vi > vii;
int mod = 1000000007;
int n, m, a[100009], j, num[10000009], nex, cur, t = 1, ans[10000009];
signed main()
{
	cin >> n >> m;
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	for(int i = 1; i <= n; i++)
	{
		j = 0;
		while(j <= 10000000)
		{
			num[j] = max(num[j], a[i]);
			j += a[i];
		}
	}
	nex = num[0];
	num[1] = num[0] - 1;
	for(int i = 2; i <= 10; i++)
	{
		int k = 0;
		while(i >= nex && cur < i)
		{
			cur ++;
			k = 1;
			nex = num[cur] + cur;
		}
		if(cur == i)
			break;
		ans[i] = ans[cur] + 1;
	}
	while(m --)
	{
		int k;
		cin >> k;
		if(ans[k])
			cout << ans[k] << endl;
		else
			cout << "oo" << endl;
	}
}

Compilation message (stderr)

brunhilda.cpp: In function 'int main()':
brunhilda.cpp:33:7: warning: variable 'k' set but not used [-Wunused-but-set-variable]
   int k = 0;
       ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...