Skip to content

Instantly share code, notes, and snippets.

@tico88612
Last active May 13, 2020 11:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tico88612/44ff9806d01ea0a3c0b6df39842f90b1 to your computer and use it in GitHub Desktop.
Save tico88612/44ff9806d01ea0a3c0b6df39842f90b1 to your computer and use it in GitHub Desktop.
/*
Author: Jerry Yang C.H. (tico88612)
Date: 2020/5/13
*/
#include <bits/stdc++.h>
using namespace std;
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
/********** Good Luck :) **********/
int main()
{
IOS();
int c[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
int p[10] = {1, 5, 8, 9, 10, 17, 17, 20, 24, 30};
int n;
cin >> n;
int dp[10000] = {0};
for(int i = 0; i < 10; i++) {
for (int j = c[i]; j <= n; j++) {
dp[j] = max(dp[j], dp[j - c[i]] + p[i]);
}
}
cout << dp[n] << '\n';
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment