10157 | 2024-03-28 19:45:07 | 111 | Az óvodai lét elviselhetetlen könnyűsége #2 | cpp17 | Wrong answer 30/100 | 115ms | 6472 KiB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define MA (int)1e4
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());
vector<int>dp(MA);
dp[0]=1;
for(int i=1;i<MA;i++){
int h=0;
for(int j=0;j<M&&v[j]>h;j++){
h=max(h,dp[i-1]*(v[j]-1)%v[j]);
}
dp[i]=dp[i-1]+h;
if(h==0||dp[i]>1e7){
fill(dp.begin()+i,dp.end(),dp[i-1]);
}
}
while(Q--){
int N;
cin>>N;
int l=0,h=MA;
while(l<h){
int m=(l+h)/2;
if(dp[m]>N){
h=m;
}
else{
l=m+1;
}
}
cout<<(h==MA?0:h)<<'\n';
}
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 29ms | 2032 KiB | ||||
2 | Accepted | 72ms | 2300 KiB | ||||
subtask2 | 20/20 | ||||||
3 | Accepted | 32ms | 2560 KiB | ||||
4 | Accepted | 35ms | 2768 KiB | ||||
5 | Accepted | 35ms | 2876 KiB | ||||
6 | Accepted | 4ms | 3140 KiB | ||||
7 | Accepted | 6ms | 3400 KiB | ||||
8 | Accepted | 14ms | 3608 KiB | ||||
9 | Accepted | 16ms | 3704 KiB | ||||
10 | Accepted | 30ms | 3848 KiB | ||||
subtask3 | 10/10 | ||||||
11 | Accepted | 59ms | 3832 KiB | ||||
12 | Accepted | 78ms | 4068 KiB | ||||
13 | Accepted | 85ms | 4272 KiB | ||||
14 | Accepted | 65ms | 4272 KiB | ||||
15 | Accepted | 48ms | 4520 KiB | ||||
16 | Accepted | 82ms | 4492 KiB | ||||
17 | Accepted | 54ms | 6008 KiB | ||||
subtask4 | 0/15 | ||||||
18 | Accepted | 45ms | 4568 KiB | ||||
19 | Accepted | 37ms | 4320 KiB | ||||
20 | Wrong answer | 41ms | 5556 KiB | ||||
21 | Accepted | 28ms | 4456 KiB | ||||
22 | Wrong answer | 115ms | 6080 KiB | ||||
23 | Accepted | 85ms | 4516 KiB | ||||
24 | Accepted | 85ms | 4516 KiB | ||||
25 | Accepted | 86ms | 4516 KiB | ||||
26 | Wrong answer | 32ms | 4784 KiB | ||||
27 | Accepted | 64ms | 5196 KiB | ||||
subtask5 | 0/55 | ||||||
28 | Wrong answer | 67ms | 6012 KiB | ||||
29 | Wrong answer | 65ms | 6036 KiB | ||||
30 | Wrong answer | 67ms | 4888 KiB | ||||
31 | Wrong answer | 61ms | 4804 KiB | ||||
32 | Wrong answer | 63ms | 5052 KiB | ||||
33 | Wrong answer | 50ms | 5096 KiB | ||||
34 | Accepted | 75ms | 4944 KiB | ||||
35 | Accepted | 107ms | 4952 KiB | ||||
36 | Wrong answer | 75ms | 5068 KiB | ||||
37 | Wrong answer | 65ms | 5216 KiB | ||||
38 | Wrong answer | 71ms | 5988 KiB | ||||
39 | Wrong answer | 75ms | 6472 KiB |