#include<bits/stdc++.h>
#define ll int
#define ld double
#define cd complex<ld>
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std ;
ll m , q ;
ll A[100005] = {} ;
void solve()
{
cin >> m >> q ;
for(int i = 1 ; i<= m ; i++) cin >> A[i] ;
vector<ll> ans ;
ll cur = 0 ;
ans.push_back(0) ;
while(cur<=10000000)
{
ll F = 0 ;
for(int j = 1 ; j<= m ; j++)
{
F = max(F , cur-cur%A[j]+A[j]-1) ;
}
if(F<=cur) break ;
ans.push_back(F) ;
cur = F ;
}
//for(int i = 0 ; i< ans.size() ; i++) cout << ans[i] << "\n" ;
for(int i = 1 ; i<= q ; i++)
{
ll k ; cin >> k ;
ll save = k ;
for(int j = 1 ; j<= m ; j++) save /= A[j] ;
if(save>0)
{
cout << "oo\n" ;
continue ;
}
ll lo = 0 , hi = ans.size() ;
hi-- ;
if(hi<0)
{
cout << "oo\n" ;
continue ;
}
while(hi-lo>1)
{
ll mid = ((hi+lo)>>1) ;
if(ans[mid]>k) hi = mid ;
else lo = mid ;
}
if(ans[hi]<=k)
{
cout << hi ;
}
else cout << lo ;
cout << "\n" ;
}
}
int main()
{
ios_base::sync_with_stdio(NULL) ; cin.tie(nullptr) ; cout.tie(nullptr) ;
//freopen("LINES.inp" , "r" , stdin) ;
//freopen("LINES.out" , "w" , stdout) ;
//freopen("IN.txt" , "r" , stdin) ;
int t = 1; //cin >> t ;
for(int i = 1 ; i<= t ; i++)
{
solve() ;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Incorrect |
8 ms |
452 KB |
Output isn't correct |
3 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
4 |
Incorrect |
7 ms |
340 KB |
Output isn't correct |
5 |
Incorrect |
13 ms |
1492 KB |
Output isn't correct |
6 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
7 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
8 |
Incorrect |
2 ms |
600 KB |
Output isn't correct |
9 |
Incorrect |
24 ms |
2476 KB |
Output isn't correct |
10 |
Incorrect |
14 ms |
876 KB |
Output isn't correct |
11 |
Incorrect |
14 ms |
984 KB |
Output isn't correct |
12 |
Incorrect |
3 ms |
340 KB |
Output isn't correct |
13 |
Incorrect |
13 ms |
340 KB |
Output isn't correct |
14 |
Incorrect |
52 ms |
336 KB |
Output isn't correct |
15 |
Incorrect |
6 ms |
468 KB |
Output isn't correct |
16 |
Incorrect |
7 ms |
428 KB |
Output isn't correct |
17 |
Incorrect |
13 ms |
476 KB |
Output isn't correct |
18 |
Incorrect |
6 ms |
340 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
340 KB |
Output isn't correct |
2 |
Incorrect |
9 ms |
596 KB |
Output isn't correct |
3 |
Incorrect |
9 ms |
596 KB |
Output isn't correct |
4 |
Correct |
2 ms |
212 KB |
Output is correct |
5 |
Incorrect |
6 ms |
468 KB |
Output isn't correct |
6 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
7 |
Incorrect |
3 ms |
340 KB |
Output isn't correct |
8 |
Incorrect |
3 ms |
212 KB |
Output isn't correct |
9 |
Incorrect |
11 ms |
596 KB |
Output isn't correct |
10 |
Incorrect |
12 ms |
600 KB |
Output isn't correct |
11 |
Incorrect |
8 ms |
468 KB |
Output isn't correct |
12 |
Correct |
3 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
2 ms |
340 KB |
Output is correct |
15 |
Incorrect |
6 ms |
468 KB |
Output isn't correct |
16 |
Incorrect |
9 ms |
596 KB |
Output isn't correct |
17 |
Incorrect |
6 ms |
340 KB |
Output isn't correct |
18 |
Incorrect |
10 ms |
712 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1084 ms |
512 KB |
Time limit exceeded |
2 |
Execution timed out |
1096 ms |
520 KB |
Time limit exceeded |
3 |
Execution timed out |
1098 ms |
508 KB |
Time limit exceeded |
4 |
Execution timed out |
1091 ms |
628 KB |
Time limit exceeded |
5 |
Execution timed out |
1087 ms |
700 KB |
Time limit exceeded |
6 |
Execution timed out |
1098 ms |
460 KB |
Time limit exceeded |
7 |
Execution timed out |
1085 ms |
716 KB |
Time limit exceeded |
8 |
Execution timed out |
1088 ms |
508 KB |
Time limit exceeded |
9 |
Execution timed out |
1090 ms |
508 KB |
Time limit exceeded |
10 |
Incorrect |
310 ms |
468 KB |
Output isn't correct |
11 |
Incorrect |
447 ms |
388 KB |
Output isn't correct |
12 |
Incorrect |
608 ms |
468 KB |
Output isn't correct |
13 |
Execution timed out |
1082 ms |
436 KB |
Time limit exceeded |
14 |
Incorrect |
58 ms |
1332 KB |
Output isn't correct |
15 |
Incorrect |
643 ms |
340 KB |
Output isn't correct |
16 |
Incorrect |
691 ms |
480 KB |
Output isn't correct |
17 |
Execution timed out |
1081 ms |
612 KB |
Time limit exceeded |
18 |
Execution timed out |
1084 ms |
528 KB |
Time limit exceeded |
19 |
Incorrect |
497 ms |
348 KB |
Output isn't correct |
20 |
Execution timed out |
1089 ms |
636 KB |
Time limit exceeded |
21 |
Incorrect |
72 ms |
1008 KB |
Output isn't correct |
22 |
Execution timed out |
1091 ms |
696 KB |
Time limit exceeded |
23 |
Execution timed out |
1090 ms |
432 KB |
Time limit exceeded |
24 |
Incorrect |
506 ms |
540 KB |
Output isn't correct |
25 |
Execution timed out |
1079 ms |
476 KB |
Time limit exceeded |
26 |
Execution timed out |
1084 ms |
500 KB |
Time limit exceeded |
27 |
Execution timed out |
1058 ms |
696 KB |
Time limit exceeded |
28 |
Incorrect |
480 ms |
612 KB |
Output isn't correct |
29 |
Execution timed out |
1086 ms |
696 KB |
Time limit exceeded |
30 |
Execution timed out |
1085 ms |
468 KB |
Time limit exceeded |
31 |
Execution timed out |
1093 ms |
460 KB |
Time limit exceeded |
32 |
Execution timed out |
1096 ms |
580 KB |
Time limit exceeded |
33 |
Incorrect |
515 ms |
564 KB |
Output isn't correct |
34 |
Execution timed out |
1090 ms |
708 KB |
Time limit exceeded |
35 |
Incorrect |
939 ms |
584 KB |
Output isn't correct |
36 |
Execution timed out |
1090 ms |
656 KB |
Time limit exceeded |
37 |
Execution timed out |
1087 ms |
688 KB |
Time limit exceeded |
38 |
Execution timed out |
1091 ms |
340 KB |
Time limit exceeded |
39 |
Execution timed out |
1058 ms |
764 KB |
Time limit exceeded |
40 |
Execution timed out |
1090 ms |
360 KB |
Time limit exceeded |
41 |
Execution timed out |
1076 ms |
688 KB |
Time limit exceeded |
42 |
Execution timed out |
1079 ms |
648 KB |
Time limit exceeded |