10154 | 2024-03-28 19:33:02 | 111 | Az óvodai lét elviselhetetlen könnyűsége #2 | cpp17 | Time limit exceeded 0/100 | 1.58s | 11884 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];
}
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 | 6ms | 3164 KiB | ||||
2 | Accepted | 301ms | 4124 KiB | ||||
subtask2 | 0/20 | ||||||
3 | Accepted | 30ms | 4300 KiB | ||||
4 | Accepted | 50ms | 4520 KiB | ||||
5 | Accepted | 63ms | 4856 KiB | ||||
6 | Accepted | 43ms | 4980 KiB | ||||
7 | Accepted | 266ms | 5040 KiB | ||||
8 | Accepted | 1.312s | 4964 KiB | ||||
9 | Time limit exceeded | 1.564s | 3860 KiB | ||||
10 | Time limit exceeded | 1.541s | 3868 KiB | ||||
subtask3 | 0/10 | ||||||
11 | Accepted | 104ms | 5792 KiB | ||||
12 | Accepted | 289ms | 6492 KiB | ||||
13 | Accepted | 354ms | 7480 KiB | ||||
14 | Accepted | 360ms | 8208 KiB | ||||
15 | Accepted | 694ms | 9048 KiB | ||||
16 | Accepted | 419ms | 9912 KiB | ||||
17 | Time limit exceeded | 1.572s | 9396 KiB | ||||
subtask4 | 0/15 | ||||||
18 | Time limit exceeded | 1.565s | 8708 KiB | ||||
19 | Time limit exceeded | 1.575s | 8760 KiB | ||||
20 | Time limit exceeded | 1.557s | 9596 KiB | ||||
21 | Time limit exceeded | 1.577s | 8824 KiB | ||||
22 | Time limit exceeded | 1.57s | 9556 KiB | ||||
23 | Accepted | 554ms | 10160 KiB | ||||
24 | Accepted | 551ms | 10156 KiB | ||||
25 | Accepted | 579ms | 10160 KiB | ||||
26 | Accepted | 875ms | 10420 KiB | ||||
27 | Time limit exceeded | 1.58s | 9396 KiB | ||||
subtask5 | 0/55 | ||||||
28 | Time limit exceeded | 1.567s | 9644 KiB | ||||
29 | Time limit exceeded | 1.562s | 9784 KiB | ||||
30 | Time limit exceeded | 1.578s | 9084 KiB | ||||
31 | Time limit exceeded | 1.549s | 9024 KiB | ||||
32 | Time limit exceeded | 1.572s | 8960 KiB | ||||
33 | Time limit exceeded | 1.562s | 8948 KiB | ||||
34 | Accepted | 370ms | 11176 KiB | ||||
35 | Accepted | 552ms | 11884 KiB | ||||
36 | Time limit exceeded | 1.529s | 10600 KiB | ||||
37 | Time limit exceeded | 1.542s | 10972 KiB | ||||
38 | Time limit exceeded | 1.554s | 11360 KiB | ||||
39 | Time limit exceeded | 1.574s | 11668 KiB |