10155 | 2024-03-28 19:34:28 | 111 | Az óvodai lét elviselhetetlen könnyűsége #2 | cpp17 | Time limit exceeded 20/100 | 1.582s | 8548 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];
}
vector<int>dp(MA);
dp[0]=1;
for(int i=1;i<MA;i++){
int h=0;
for(int j=0;j<M;j++){
h=max(h,dp[i-1]*(v[j]-1)%v[j]);
}
dp[i]=dp[i-1]+h;
}
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 | 3ms | 2032 KiB | ||||
2 | Accepted | 52ms | 2460 KiB | ||||
subtask2 | 20/20 | ||||||
3 | Accepted | 6ms | 2884 KiB | ||||
4 | Accepted | 8ms | 2744 KiB | ||||
5 | Accepted | 9ms | 2868 KiB | ||||
6 | Accepted | 8ms | 2732 KiB | ||||
7 | Accepted | 29ms | 2996 KiB | ||||
8 | Accepted | 135ms | 3172 KiB | ||||
9 | Accepted | 264ms | 3120 KiB | ||||
10 | Accepted | 592ms | 3272 KiB | ||||
subtask3 | 0/10 | ||||||
11 | Accepted | 32ms | 3504 KiB | ||||
12 | Accepted | 52ms | 3616 KiB | ||||
13 | Accepted | 57ms | 3592 KiB | ||||
14 | Accepted | 56ms | 3640 KiB | ||||
15 | Accepted | 89ms | 3648 KiB | ||||
16 | Accepted | 64ms | 3868 KiB | ||||
17 | Time limit exceeded | 1.565s | 3780 KiB | ||||
subtask4 | 0/15 | ||||||
18 | Accepted | 411ms | 4180 KiB | ||||
19 | Accepted | 279ms | 4340 KiB | ||||
20 | Time limit exceeded | 1.582s | 4428 KiB | ||||
21 | Accepted | 395ms | 4876 KiB | ||||
22 | Time limit exceeded | 1.575s | 4932 KiB | ||||
23 | Accepted | 57ms | 4808 KiB | ||||
24 | Accepted | 57ms | 4832 KiB | ||||
25 | Accepted | 59ms | 4984 KiB | ||||
26 | Accepted | 90ms | 4716 KiB | ||||
27 | Time limit exceeded | 1.555s | 4200 KiB | ||||
subtask5 | 0/55 | ||||||
28 | Time limit exceeded | 1.542s | 4696 KiB | ||||
29 | Time limit exceeded | 1.57s | 4736 KiB | ||||
30 | Accepted | 1.09s | 5560 KiB | ||||
31 | Accepted | 328ms | 6204 KiB | ||||
32 | Accepted | 1.259s | 6860 KiB | ||||
33 | Accepted | 416ms | 7504 KiB | ||||
34 | Accepted | 65ms | 7472 KiB | ||||
35 | Accepted | 79ms | 7680 KiB | ||||
36 | Accepted | 1.34s | 8392 KiB | ||||
37 | Time limit exceeded | 1.555s | 8548 KiB | ||||
38 | Time limit exceeded | 1.542s | 8028 KiB | ||||
39 | Time limit exceeded | 1.562s | 8352 KiB |