10158 | 2024-03-28 19:45:50 | 111 | Az óvodai lét elviselhetetlen könnyűsége #2 | cpp17 | Time limit exceeded 0/100 | 1.582s | 5736 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());
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 | Time limit exceeded | 1.562s | 1992 KiB | ||||
2 | Time limit exceeded | 1.582s | 2148 KiB | ||||
subtask2 | 0/20 | ||||||
3 | Time limit exceeded | 1.547s | 2228 KiB | ||||
4 | Time limit exceeded | 1.565s | 2584 KiB | ||||
5 | Time limit exceeded | 1.539s | 2980 KiB | ||||
6 | Accepted | 17ms | 4380 KiB | ||||
7 | Time limit exceeded | 1.521s | 2836 KiB | ||||
8 | Time limit exceeded | 1.55s | 2888 KiB | ||||
9 | Time limit exceeded | 1.574s | 2884 KiB | ||||
10 | Time limit exceeded | 1.554s | 2952 KiB | ||||
subtask3 | 0/10 | ||||||
11 | Time limit exceeded | 1.565s | 3188 KiB | ||||
12 | Time limit exceeded | 1.574s | 3560 KiB | ||||
13 | Time limit exceeded | 1.575s | 3448 KiB | ||||
14 | Time limit exceeded | 1.57s | 3584 KiB | ||||
15 | Time limit exceeded | 1.562s | 3652 KiB | ||||
16 | Time limit exceeded | 1.567s | 3576 KiB | ||||
17 | Time limit exceeded | 1.57s | 4320 KiB | ||||
subtask4 | 0/15 | ||||||
18 | Time limit exceeded | 1.57s | 3496 KiB | ||||
19 | Time limit exceeded | 1.562s | 3760 KiB | ||||
20 | Time limit exceeded | 1.549s | 4516 KiB | ||||
21 | Time limit exceeded | 1.582s | 3796 KiB | ||||
22 | Time limit exceeded | 1.559s | 4444 KiB | ||||
23 | Time limit exceeded | 1.574s | 3992 KiB | ||||
24 | Time limit exceeded | 1.554s | 4004 KiB | ||||
25 | Time limit exceeded | 1.57s | 4328 KiB | ||||
26 | Time limit exceeded | 1.567s | 4288 KiB | ||||
27 | Time limit exceeded | 1.565s | 4884 KiB | ||||
subtask5 | 0/55 | ||||||
28 | Time limit exceeded | 1.562s | 5112 KiB | ||||
29 | Time limit exceeded | 1.57s | 5416 KiB | ||||
30 | Time limit exceeded | 1.534s | 4592 KiB | ||||
31 | Time limit exceeded | 1.557s | 4584 KiB | ||||
32 | Time limit exceeded | 1.546s | 4628 KiB | ||||
33 | Time limit exceeded | 1.562s | 4640 KiB | ||||
34 | Time limit exceeded | 1.562s | 4612 KiB | ||||
35 | Time limit exceeded | 1.549s | 4676 KiB | ||||
36 | Time limit exceeded | 1.574s | 4812 KiB | ||||
37 | Time limit exceeded | 1.574s | 4932 KiB | ||||
38 | Time limit exceeded | 1.562s | 5548 KiB | ||||
39 | Time limit exceeded | 1.547s | 5736 KiB |