#include <bits/stdc++.h>
using namespace std;
int n,q;
int a[100009];
int main()
{
cin>>n>>q;
for(int i=0;i<n;i++)cin>>a[i];
sort(a,a+n);
int x;
while (q--)
{
cin>>x;
int re=0;
bool r=0;
for(int i=n-1;i>-1;i--)
{
if (x<a[n-1])
{
r=1;
cout<<re+1;
break;
}
if (x==0)
{
r=1;
cout<<re<<endl;break;
}
if (x%a[i]!=0){x=x-(x%a[i]);
re++;}
}
if (r==0&&x<a[n-1])
cout<<re+1<<endl;
else if (r==0)cout<<"oo"<<endl;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
256 KB |
Output isn't correct |
2 |
Incorrect |
4 ms |
256 KB |
Output isn't correct |
3 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
4 |
Incorrect |
32 ms |
376 KB |
Output isn't correct |
5 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
6 |
Incorrect |
5 ms |
256 KB |
Output isn't correct |
7 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
8 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
9 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
10 |
Incorrect |
5 ms |
376 KB |
Output isn't correct |
11 |
Incorrect |
5 ms |
376 KB |
Output isn't correct |
12 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
13 |
Incorrect |
5 ms |
376 KB |
Output isn't correct |
14 |
Incorrect |
30 ms |
376 KB |
Output isn't correct |
15 |
Incorrect |
3 ms |
256 KB |
Output isn't correct |
16 |
Incorrect |
4 ms |
256 KB |
Output isn't correct |
17 |
Incorrect |
38 ms |
580 KB |
Output isn't correct |
18 |
Incorrect |
32 ms |
376 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
500 KB |
Output isn't correct |
2 |
Correct |
61 ms |
1396 KB |
Output is correct |
3 |
Correct |
43 ms |
1016 KB |
Output is correct |
4 |
Incorrect |
4 ms |
376 KB |
Output isn't correct |
5 |
Correct |
33 ms |
888 KB |
Output is correct |
6 |
Incorrect |
3 ms |
380 KB |
Output isn't correct |
7 |
Incorrect |
9 ms |
376 KB |
Output isn't correct |
8 |
Incorrect |
3 ms |
256 KB |
Output isn't correct |
9 |
Incorrect |
45 ms |
1144 KB |
Output isn't correct |
10 |
Correct |
43 ms |
1144 KB |
Output is correct |
11 |
Incorrect |
26 ms |
760 KB |
Output isn't correct |
12 |
Incorrect |
3 ms |
376 KB |
Output isn't correct |
13 |
Incorrect |
4 ms |
376 KB |
Output isn't correct |
14 |
Incorrect |
4 ms |
376 KB |
Output isn't correct |
15 |
Incorrect |
27 ms |
760 KB |
Output isn't correct |
16 |
Correct |
62 ms |
1272 KB |
Output is correct |
17 |
Incorrect |
4 ms |
376 KB |
Output isn't correct |
18 |
Incorrect |
66 ms |
1404 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1073 ms |
1076 KB |
Time limit exceeded |
2 |
Execution timed out |
1077 ms |
1076 KB |
Time limit exceeded |
3 |
Execution timed out |
1076 ms |
1056 KB |
Time limit exceeded |
4 |
Execution timed out |
1071 ms |
888 KB |
Time limit exceeded |
5 |
Execution timed out |
1083 ms |
1784 KB |
Time limit exceeded |
6 |
Execution timed out |
1077 ms |
904 KB |
Time limit exceeded |
7 |
Execution timed out |
1072 ms |
1656 KB |
Time limit exceeded |
8 |
Execution timed out |
1072 ms |
1068 KB |
Time limit exceeded |
9 |
Execution timed out |
1078 ms |
1104 KB |
Time limit exceeded |
10 |
Incorrect |
759 ms |
632 KB |
Output isn't correct |
11 |
Execution timed out |
1078 ms |
732 KB |
Time limit exceeded |
12 |
Execution timed out |
1079 ms |
652 KB |
Time limit exceeded |
13 |
Execution timed out |
1089 ms |
760 KB |
Time limit exceeded |
14 |
Incorrect |
344 ms |
1488 KB |
Output isn't correct |
15 |
Execution timed out |
1082 ms |
788 KB |
Time limit exceeded |
16 |
Execution timed out |
1088 ms |
780 KB |
Time limit exceeded |
17 |
Execution timed out |
1080 ms |
888 KB |
Time limit exceeded |
18 |
Execution timed out |
1073 ms |
1144 KB |
Time limit exceeded |
19 |
Incorrect |
953 ms |
760 KB |
Output isn't correct |
20 |
Execution timed out |
1086 ms |
1016 KB |
Time limit exceeded |
21 |
Incorrect |
444 ms |
1600 KB |
Output isn't correct |
22 |
Execution timed out |
1080 ms |
1528 KB |
Time limit exceeded |
23 |
Execution timed out |
1089 ms |
888 KB |
Time limit exceeded |
24 |
Execution timed out |
1081 ms |
1180 KB |
Time limit exceeded |
25 |
Execution timed out |
1080 ms |
804 KB |
Time limit exceeded |
26 |
Execution timed out |
1091 ms |
888 KB |
Time limit exceeded |
27 |
Execution timed out |
1079 ms |
1656 KB |
Time limit exceeded |
28 |
Execution timed out |
1080 ms |
1472 KB |
Time limit exceeded |
29 |
Execution timed out |
1088 ms |
1636 KB |
Time limit exceeded |
30 |
Execution timed out |
1074 ms |
1272 KB |
Time limit exceeded |
31 |
Execution timed out |
1075 ms |
896 KB |
Time limit exceeded |
32 |
Execution timed out |
1064 ms |
1000 KB |
Time limit exceeded |
33 |
Execution timed out |
1077 ms |
1324 KB |
Time limit exceeded |
34 |
Execution timed out |
1077 ms |
1648 KB |
Time limit exceeded |
35 |
Execution timed out |
1069 ms |
1068 KB |
Time limit exceeded |
36 |
Execution timed out |
1071 ms |
1596 KB |
Time limit exceeded |
37 |
Execution timed out |
1088 ms |
1768 KB |
Time limit exceeded |
38 |
Execution timed out |
1074 ms |
940 KB |
Time limit exceeded |
39 |
Execution timed out |
1072 ms |
1148 KB |
Time limit exceeded |
40 |
Execution timed out |
1087 ms |
1016 KB |
Time limit exceeded |
41 |
Incorrect |
244 ms |
1812 KB |
Output isn't correct |
42 |
Execution timed out |
1074 ms |
948 KB |
Time limit exceeded |