#include <bits/stdc++.h>
using namespace std;
#define ll long long
long long m, q, pd=1, x, vl;
vector<ll> p;
int main()
{
cin.tie(NULL)->sync_with_stdio(false);
cin>>m>>q;
for (int i=1; i<=m; i++) cin>>x, pd=min((long long)10000005, pd*x), p.push_back(x);
while (q--)
{
cin>>vl;
long long tmp=vl/x*x, res=0;
for (auto t:p) if (vl-(vl%t)<tmp) res=1;
if (vl%x==0) res=0;
if (vl>=pd) cout<<"oo\n";
else cout<<2*(vl/x)+((vl%x)!=0)-res<<'\n';
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
5 ms |
348 KB |
Output is correct |
5 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
6 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
5 ms |
468 KB |
Output is correct |
14 |
Correct |
41 ms |
468 KB |
Output is correct |
15 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
16 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
17 |
Incorrect |
4 ms |
348 KB |
Output isn't correct |
18 |
Correct |
5 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
600 KB |
Output isn't correct |
2 |
Correct |
7 ms |
1496 KB |
Output is correct |
3 |
Correct |
5 ms |
1496 KB |
Output is correct |
4 |
Incorrect |
0 ms |
600 KB |
Output isn't correct |
5 |
Correct |
4 ms |
992 KB |
Output is correct |
6 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
7 |
Incorrect |
1 ms |
604 KB |
Output isn't correct |
8 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
9 |
Correct |
6 ms |
1500 KB |
Output is correct |
10 |
Correct |
6 ms |
1500 KB |
Output is correct |
11 |
Incorrect |
3 ms |
1020 KB |
Output isn't correct |
12 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
13 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
14 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
15 |
Incorrect |
3 ms |
988 KB |
Output isn't correct |
16 |
Correct |
7 ms |
1500 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
8 ms |
1500 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1054 ms |
1232 KB |
Time limit exceeded |
2 |
Execution timed out |
1064 ms |
1236 KB |
Time limit exceeded |
3 |
Execution timed out |
1064 ms |
992 KB |
Time limit exceeded |
4 |
Execution timed out |
1006 ms |
1104 KB |
Time limit exceeded |
5 |
Execution timed out |
1020 ms |
1496 KB |
Time limit exceeded |
6 |
Execution timed out |
1062 ms |
832 KB |
Time limit exceeded |
7 |
Execution timed out |
1061 ms |
1416 KB |
Time limit exceeded |
8 |
Execution timed out |
1051 ms |
988 KB |
Time limit exceeded |
9 |
Execution timed out |
1072 ms |
992 KB |
Time limit exceeded |
10 |
Incorrect |
351 ms |
564 KB |
Output isn't correct |
11 |
Incorrect |
515 ms |
804 KB |
Output isn't correct |
12 |
Incorrect |
687 ms |
868 KB |
Output isn't correct |
13 |
Execution timed out |
1042 ms |
1080 KB |
Time limit exceeded |
14 |
Incorrect |
36 ms |
852 KB |
Output isn't correct |
15 |
Incorrect |
737 ms |
824 KB |
Output isn't correct |
16 |
Incorrect |
807 ms |
892 KB |
Output isn't correct |
17 |
Execution timed out |
1046 ms |
1184 KB |
Time limit exceeded |
18 |
Execution timed out |
1074 ms |
992 KB |
Time limit exceeded |
19 |
Incorrect |
531 ms |
596 KB |
Output isn't correct |
20 |
Execution timed out |
1058 ms |
992 KB |
Time limit exceeded |
21 |
Correct |
80 ms |
904 KB |
Output is correct |
22 |
Execution timed out |
1074 ms |
1500 KB |
Time limit exceeded |
23 |
Execution timed out |
1060 ms |
736 KB |
Time limit exceeded |
24 |
Incorrect |
572 ms |
592 KB |
Output isn't correct |
25 |
Execution timed out |
1061 ms |
764 KB |
Time limit exceeded |
26 |
Execution timed out |
1036 ms |
888 KB |
Time limit exceeded |
27 |
Execution timed out |
1058 ms |
1500 KB |
Time limit exceeded |
28 |
Incorrect |
565 ms |
988 KB |
Output isn't correct |
29 |
Execution timed out |
1035 ms |
1496 KB |
Time limit exceeded |
30 |
Execution timed out |
1044 ms |
1496 KB |
Time limit exceeded |
31 |
Execution timed out |
1093 ms |
660 KB |
Time limit exceeded |
32 |
Execution timed out |
1088 ms |
592 KB |
Time limit exceeded |
33 |
Incorrect |
570 ms |
592 KB |
Output isn't correct |
34 |
Execution timed out |
1041 ms |
1500 KB |
Time limit exceeded |
35 |
Execution timed out |
1035 ms |
1256 KB |
Time limit exceeded |
36 |
Execution timed out |
1044 ms |
1500 KB |
Time limit exceeded |
37 |
Execution timed out |
1069 ms |
1500 KB |
Time limit exceeded |
38 |
Execution timed out |
1033 ms |
632 KB |
Time limit exceeded |
39 |
Execution timed out |
1040 ms |
760 KB |
Time limit exceeded |
40 |
Execution timed out |
1063 ms |
856 KB |
Time limit exceeded |
41 |
Execution timed out |
1041 ms |
1500 KB |
Time limit exceeded |
42 |
Execution timed out |
1067 ms |
684 KB |
Time limit exceeded |