101522024-03-28 18:03:27111Az óvodai lét elviselhetetlen könnyűsége #2cpp17Time limit exceeded 0/1001.59s158084 KiB
#include <bits/stdc++.h>
using namespace std;

#define int long long

#define INF (int)1e18

#define MN (int)1e7 + 1

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(MN,INF);
	dp[0]=0;
	for(int i=1;i<MN;i++){
		for(int j:v){
			if(i-(i%j)>=0){
				dp[i]=min(dp[i],dp[i-(i%j)]+1);
			}
		}
	}
	while(Q--){
		int N;
		cin>>N;
		cout<<(dp[N]%INF)<<'\n';
	}
	return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted351ms158084 KiB
2Time limit exceeded1.559s79632 KiB
subtask20/20
3Time limit exceeded1.539s79896 KiB
4Time limit exceeded1.565s80276 KiB
5Time limit exceeded1.57s80404 KiB
6Time limit exceeded1.574s80480 KiB
7Time limit exceeded1.575s80656 KiB
8Time limit exceeded1.564s81008 KiB
9Time limit exceeded1.559s81184 KiB
10Time limit exceeded1.567s80996 KiB
subtask30/10
11Time limit exceeded1.59s81296 KiB
12Time limit exceeded1.565s81376 KiB
13Time limit exceeded1.575s81368 KiB
14Time limit exceeded1.57s81628 KiB
15Time limit exceeded1.58s81788 KiB
16Time limit exceeded1.583s81952 KiB
17Time limit exceeded1.572s83920 KiB
subtask40/15
18Time limit exceeded1.575s83332 KiB
19Time limit exceeded1.557s83196 KiB
20Time limit exceeded1.58s84668 KiB
21Time limit exceeded1.562s84060 KiB
22Time limit exceeded1.562s85848 KiB
23Time limit exceeded1.542s85020 KiB
24Time limit exceeded1.559s84892 KiB
25Time limit exceeded1.547s84900 KiB
26Time limit exceeded1.574s84848 KiB
27Time limit exceeded1.567s85684 KiB
subtask50/55
28Time limit exceeded1.588s87292 KiB
29Time limit exceeded1.559s88004 KiB
30Time limit exceeded1.578s87484 KiB
31Time limit exceeded1.554s87400 KiB
32Time limit exceeded1.575s87792 KiB
33Time limit exceeded1.577s87780 KiB
34Time limit exceeded1.554s87852 KiB
35Time limit exceeded1.565s88008 KiB
36Time limit exceeded1.577s88092 KiB
37Time limit exceeded1.565s88584 KiB
38Time limit exceeded1.577s89616 KiB
39Time limit exceeded1.575s90728 KiB