#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<<"00"<<endl;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
376 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 |
376 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 |
376 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 |
6 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 |
376 KB |
Output isn't correct |
17 |
Incorrect |
37 ms |
376 KB |
Output isn't correct |
18 |
Incorrect |
32 ms |
376 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
9 ms |
504 KB |
Output isn't correct |
2 |
Correct |
61 ms |
1400 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 |
376 KB |
Output isn't correct |
7 |
Incorrect |
9 ms |
376 KB |
Output isn't correct |
8 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
9 |
Incorrect |
44 ms |
1144 KB |
Output isn't correct |
10 |
Correct |
43 ms |
1144 KB |
Output is correct |
11 |
Incorrect |
25 ms |
760 KB |
Output isn't correct |
12 |
Incorrect |
3 ms |
376 KB |
Output isn't correct |
13 |
Incorrect |
3 ms |
376 KB |
Output isn't correct |
14 |
Incorrect |
3 ms |
376 KB |
Output isn't correct |
15 |
Incorrect |
27 ms |
760 KB |
Output isn't correct |
16 |
Correct |
61 ms |
1400 KB |
Output is correct |
17 |
Incorrect |
3 ms |
376 KB |
Output isn't correct |
18 |
Incorrect |
64 ms |
1164 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1081 ms |
1188 KB |
Time limit exceeded |
2 |
Execution timed out |
1082 ms |
1020 KB |
Time limit exceeded |
3 |
Execution timed out |
1085 ms |
1076 KB |
Time limit exceeded |
4 |
Execution timed out |
1079 ms |
888 KB |
Time limit exceeded |
5 |
Execution timed out |
1081 ms |
1400 KB |
Time limit exceeded |
6 |
Execution timed out |
1082 ms |
1048 KB |
Time limit exceeded |
7 |
Execution timed out |
1080 ms |
1432 KB |
Time limit exceeded |
8 |
Execution timed out |
1083 ms |
1148 KB |
Time limit exceeded |
9 |
Execution timed out |
1076 ms |
1092 KB |
Time limit exceeded |
10 |
Incorrect |
759 ms |
504 KB |
Output isn't correct |
11 |
Execution timed out |
1083 ms |
892 KB |
Time limit exceeded |
12 |
Execution timed out |
1085 ms |
764 KB |
Time limit exceeded |
13 |
Execution timed out |
1085 ms |
888 KB |
Time limit exceeded |
14 |
Incorrect |
342 ms |
1292 KB |
Output isn't correct |
15 |
Execution timed out |
1074 ms |
764 KB |
Time limit exceeded |
16 |
Execution timed out |
1054 ms |
760 KB |
Time limit exceeded |
17 |
Execution timed out |
1064 ms |
1072 KB |
Time limit exceeded |
18 |
Execution timed out |
1077 ms |
1068 KB |
Time limit exceeded |
19 |
Incorrect |
957 ms |
760 KB |
Output isn't correct |
20 |
Execution timed out |
1082 ms |
1056 KB |
Time limit exceeded |
21 |
Incorrect |
443 ms |
1284 KB |
Output isn't correct |
22 |
Execution timed out |
1086 ms |
1272 KB |
Time limit exceeded |
23 |
Execution timed out |
1068 ms |
996 KB |
Time limit exceeded |
24 |
Execution timed out |
1083 ms |
1084 KB |
Time limit exceeded |
25 |
Execution timed out |
1079 ms |
792 KB |
Time limit exceeded |
26 |
Execution timed out |
1065 ms |
1036 KB |
Time limit exceeded |
27 |
Execution timed out |
1085 ms |
1268 KB |
Time limit exceeded |
28 |
Execution timed out |
1082 ms |
1036 KB |
Time limit exceeded |
29 |
Execution timed out |
1087 ms |
1272 KB |
Time limit exceeded |
30 |
Execution timed out |
1074 ms |
1272 KB |
Time limit exceeded |
31 |
Execution timed out |
1066 ms |
796 KB |
Time limit exceeded |
32 |
Execution timed out |
1087 ms |
1156 KB |
Time limit exceeded |
33 |
Execution timed out |
1081 ms |
1172 KB |
Time limit exceeded |
34 |
Execution timed out |
1081 ms |
1372 KB |
Time limit exceeded |
35 |
Execution timed out |
1085 ms |
1044 KB |
Time limit exceeded |
36 |
Execution timed out |
1084 ms |
1400 KB |
Time limit exceeded |
37 |
Execution timed out |
1084 ms |
1524 KB |
Time limit exceeded |
38 |
Execution timed out |
1080 ms |
820 KB |
Time limit exceeded |
39 |
Execution timed out |
1079 ms |
1272 KB |
Time limit exceeded |
40 |
Execution timed out |
1080 ms |
1028 KB |
Time limit exceeded |
41 |
Incorrect |
248 ms |
1272 KB |
Output isn't correct |
42 |
Execution timed out |
1076 ms |
888 KB |
Time limit exceeded |