10159 | 2024-03-28 19:50:14 | 111 | Az óvodai lét elviselhetetlen könnyűsége #2 | cpp17 | Wrong answer 30/100 | 48ms | 7852 KiB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define MA (int)1e5
signed main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int M,Q;
cin>>M>>Q;
vector<int>v(M);
for(int i=0;i<M;i++){
cin>>v[i];
}
sort(v.rbegin(),v.rend());
int A=1e5;
vector<int>dp(A);
dp[0]=1;
for(int i=1;i<A;i++){
int h=0;
for(int j=0;j<M&&j<100&&v[j]>h;j++){
h=max(h,dp[i-1]*(v[j]-1)%v[j]);
}
if(h==0||dp[i-1]>1e7){
A=i;
}
dp[i]=dp[i-1]+h;
}
while(Q--){
int N;
cin>>N;
int l=0,h=A;
while(l<h){
int m=(l+h)/2;
if(dp[m]>N){
h=m;
}
else{
l=m+1;
}
}
cout<<(h==A?0:h)<<'\n';
}
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 3164 KiB | ||||
2 | Accepted | 25ms | 3524 KiB | ||||
subtask2 | 20/20 | ||||||
3 | Accepted | 4ms | 3828 KiB | ||||
4 | Accepted | 4ms | 4012 KiB | ||||
5 | Accepted | 4ms | 4116 KiB | ||||
6 | Accepted | 17ms | 4072 KiB | ||||
7 | Accepted | 9ms | 4072 KiB | ||||
8 | Accepted | 7ms | 4072 KiB | ||||
9 | Accepted | 8ms | 4380 KiB | ||||
10 | Accepted | 7ms | 4592 KiB | ||||
subtask3 | 10/10 | ||||||
11 | Accepted | 23ms | 4860 KiB | ||||
12 | Accepted | 24ms | 4772 KiB | ||||
13 | Accepted | 24ms | 4968 KiB | ||||
14 | Accepted | 23ms | 4988 KiB | ||||
15 | Accepted | 21ms | 4992 KiB | ||||
16 | Accepted | 24ms | 5248 KiB | ||||
17 | Accepted | 28ms | 6580 KiB | ||||
subtask4 | 0/15 | ||||||
18 | Wrong answer | 3ms | 4932 KiB | ||||
19 | Accepted | 3ms | 5236 KiB | ||||
20 | Accepted | 16ms | 6844 KiB | ||||
21 | Accepted | 4ms | 5284 KiB | ||||
22 | Wrong answer | 17ms | 7008 KiB | ||||
23 | Accepted | 3ms | 5408 KiB | ||||
24 | Accepted | 3ms | 5344 KiB | ||||
25 | Accepted | 3ms | 5348 KiB | ||||
26 | Accepted | 3ms | 5492 KiB | ||||
27 | Accepted | 14ms | 6512 KiB | ||||
subtask5 | 0/55 | ||||||
28 | Accepted | 37ms | 7116 KiB | ||||
29 | Accepted | 35ms | 7196 KiB | ||||
30 | Wrong answer | 27ms | 5696 KiB | ||||
31 | Wrong answer | 28ms | 5652 KiB | ||||
32 | Accepted | 26ms | 5956 KiB | ||||
33 | Wrong answer | 26ms | 5864 KiB | ||||
34 | Accepted | 32ms | 5848 KiB | ||||
35 | Accepted | 28ms | 6060 KiB | ||||
36 | Wrong answer | 32ms | 6404 KiB | ||||
37 | Accepted | 30ms | 6488 KiB | ||||
38 | Accepted | 41ms | 7136 KiB | ||||
39 | Accepted | 48ms | 7852 KiB |