Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define INF 0x3f3f3f3f
- using namespace std;
- inline void min_self(int& a, int b) {
- a = min(a, b);
- }
- int main() {
- ios_base::sync_with_stdio(false);
- cin.tie(nullptr);
- cout.tie(nullptr);
- int K, N;
- cin >> K >> N;
- vector < int > a(N);
- for(int& x : a)
- cin >> x;
- vector < int > dp(16384, INF);
- int index = 0;
- dp[index] = 0;
- while(dp[index] <= K) {
- for(int x : a)
- min_self(dp[index + x], dp[index] + 1);
- ++index;
- }
- cout << index - 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment