#include using namespace std; using ll = long long; using P = pair; #define fix(x) fixed << setprecision(x) #define asc(x) x, vector, greater #define rep(i, n) for(ll i = 0; i < n; i++) #define all(x) (x).begin(),(x).end() templatebool chmin(T&a, const T&b){if(a>b){a=b;return 1;}return 0;} templatebool chmax(T&a, const T&b){if(a> n >> a >> b >> c; vector dp(1000,0); ll ans = (n/300) * max({a*100, b*60, c*30}); n %= 300; rep(i,n){ chmax(dp[i+3], dp[i]+a); chmax(dp[i+5], dp[i]+b); chmax(dp[i+10], dp[i]+c); } cout << dp[n]+ans << '\n'; return 0; }