結果
問題 | No.2386 Udon Coupon (Easy) |
ユーザー |
![]() |
提出日時 | 2023-07-21 21:32:54 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 2,294 bytes |
コンパイル時間 | 1,162 ms |
コンパイル使用メモリ | 123,572 KB |
最終ジャッジ日時 | 2025-02-15 16:25:23 |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 37 |
ソースコード
#include<iostream>#include<cstdio>#include<string>#include<cmath>#include<algorithm>#include<map>#include<vector>#include<stack>#include<iomanip>#include<queue>#include<set>#include<functional>#include<tuple>#include<bitset>#include<cassert>#include<cstdint>#include<complex>#include<random>using namespace std;bool printb(bool f) {if (f)printf("Yes\n");else printf("No\n");return f;}template<class T>void prt(T t = "", string sep = "\n") { cout << t << sep; return; }template<class T>void printl(vector<T> a, string sep = " ") {for (int i = 0; i < a.size(); i++) {cout << a[i];if (i != a.size() - 1)cout << sep;}if (sep != "\n")cout << "\n";return;}bool prt_isfixed = false;template<class T>void prt_fix(T t, string sep = "\n") {if (!prt_isfixed) {cout << fixed << setprecision(15);prt_isfixed = true;}prt(t, sep);}#define all(a) a.begin(),a.end()#define rep(i, n) for (int i = 0; i < (int)(n); i++)using uint = unsigned int;using llong = long long;using ullong = unsigned long long;using pii = pair<int, int>;using pll = pair<llong, llong>;using pli = pair<llong, int>;using pil = pair<int, llong>;template<typename T> using vec2 = vector<vector<T>>;template<typename T> inline bool chmin(T& a, T b) { return (a > b) ? (a = b, true) : false; }template<typename T> inline bool chmax(T& a, T b) { return (a < b) ? (a = b, true) : false; }bool bitIn(llong a, int b) { return ((a >> b) & 1); }int bitCnt(llong a) {int re = 0;while (a > 0) {if (a & 1)re++;a >>= 1;}return re;}llong powL(llong n, llong i) {llong re = 1;while (i >= 1) {if (i & 1) re *= n;n *= n;i >>= 1;}return re;}llong powL_M(llong n, llong i, llong mod) {llong re = 1;while (i >= 1) {if (i & 1) {re *= n;re %= mod;}n *= n;n %= mod;i >>= 1;}return re;}int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };int dx8[8] = { 0,1,1,1,0,-1,-1,-1 }, dy8[8] = { -1,-1,0,1,1,1,0,-1 };int main() {int n, a, b, c;cin >> n >> a >> b >> c;vector<int> dp(n + 1,0);dp[0] = 0;rep(i, n) {if (i + 3 <= n)chmax(dp[i + 3], dp[i] + a);if (i + 5 <= n)chmax(dp[i + 5], dp[i] + b);if (i + 10 <= n)chmax(dp[i + 10], dp[i] + c);}int re = 0;rep(i, n+1)chmax(re, dp[i]);prt(re);}