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>
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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |