1232 | 2022-03-27 13:56:02 | Valaki2 | Az óvodai lét elviselhetetlen könnyűsége #2 | cpp14 | Runtime error 20/100 | 1.595s | 8044 KiB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
int n, q;
vector<int> v;
void solve() {
cin >> n >> q;
v.assign(n, 0);
int maxi = 0;
for(int i = 0; i < n; i++) {
cin >> v[i];
maxi = max(maxi, v[i]);
}
// subtask 3
/*for(int i = 0; i < q; i++) {
int x;
cin >> x;
cout << (x < maxi ? 1 : 0) << "\n";
}*/
vector<int> dp(5001, 0);
for(int i = 1; i <= 5000; i++) {
dp[i] = 1e9;
for(int x : v) {
dp[i] = min(dp[i], dp[i / x * x] + 1);
}
}
while(q--) {
int x;
cin >> x;
cout << (dp[x] == 1e9 ? 0 : dp[x]) << "\n";
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
solve();
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 2ms | 2024 KiB | ||||
2 | Runtime error | 6ms | 2076 KiB | ||||
subtask2 | 20/20 | ||||||
3 | Accepted | 3ms | 2060 KiB | ||||
4 | Accepted | 3ms | 2084 KiB | ||||
5 | Accepted | 3ms | 2108 KiB | ||||
6 | Accepted | 3ms | 2136 KiB | ||||
7 | Accepted | 6ms | 2160 KiB | ||||
8 | Accepted | 28ms | 2188 KiB | ||||
9 | Accepted | 59ms | 2216 KiB | ||||
10 | Accepted | 101ms | 2368 KiB | ||||
subtask3 | 0/10 | ||||||
11 | Runtime error | 3ms | 2404 KiB | ||||
12 | Runtime error | 8ms | 2352 KiB | ||||
13 | Runtime error | 7ms | 2440 KiB | ||||
14 | Runtime error | 8ms | 2456 KiB | ||||
15 | Wrong answer | 30ms | 2932 KiB | ||||
16 | Runtime error | 8ms | 3000 KiB | ||||
17 | Time limit exceeded | 1.595s | 3316 KiB | ||||
subtask4 | 0/15 | ||||||
18 | Runtime error | 71ms | 3904 KiB | ||||
19 | Runtime error | 46ms | 3920 KiB | ||||
20 | Time limit exceeded | 1.57s | 3884 KiB | ||||
21 | Runtime error | 68ms | 4648 KiB | ||||
22 | Time limit exceeded | 1.552s | 4864 KiB | ||||
23 | Runtime error | 10ms | 5300 KiB | ||||
24 | Runtime error | 10ms | 5280 KiB | ||||
25 | Runtime error | 10ms | 5380 KiB | ||||
26 | Runtime error | 16ms | 5396 KiB | ||||
27 | Runtime error | 1.11s | 6012 KiB | ||||
subtask5 | 0/55 | ||||||
28 | Time limit exceeded | 1.519s | 5836 KiB | ||||
29 | Time limit exceeded | 1.549s | 6840 KiB | ||||
30 | Runtime error | 181ms | 7676 KiB | ||||
31 | Runtime error | 52ms | 7700 KiB | ||||
32 | Runtime error | 210ms | 8044 KiB | ||||
33 | Runtime error | 70ms | 5616 KiB | ||||
34 | Runtime error | 7ms | 5660 KiB | ||||
35 | Runtime error | 9ms | 5620 KiB | ||||
36 | Runtime error | 225ms | 5948 KiB | ||||
37 | Runtime error | 462ms | 6380 KiB | ||||
38 | Time limit exceeded | 1.549s | 6248 KiB | ||||
39 | Time limit exceeded | 1.524s | 7256 KiB |