結果

問題 No.2390 Udon Coupon (Hard)
ユーザー PCTprobability
提出日時 2023-06-27 03:56:55
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
RE  
実行時間 -
コード長 883 bytes
コンパイル時間 3,766 ms
コンパイル使用メモリ 251,684 KB
最終ジャッジ日時 2025-02-15 02:32:29
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 RE * 1
other AC * 20 RE * 19 MLE * 1 -- * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
 
#define elif else if
#define ll long long
#define vll vector<long long>
#define vec vector
#define embk emplace_back
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rep3(i, n, k) for (ll i = k; i < n; i++)
#define all(a) a.begin(), a.end()
#define YNeos(bool) (bool ? "Yes" : "No")
 
using namespace std;
using namespace atcoder;
const ll INF = 1LL << 60;
const ll mod = 998244353;
const double pi = acos(-1);

int main() {
  ll n; cin >> n;
  vll a(3), b(3); rep(i, 3) cin >> a[i] >> b[i];
  ll k = lcm(a[0], lcm(a[1], a[2]));
  ll k3 = k * 3;

  vll dp(k3 + 110);  //dp[うどん札の枚数] = 割引額の最大
  rep(i, k3) {
    rep(j, 3) {
      dp[i+a[j]] = max(dp[i+a[j]], dp[i] + b[j]);
    }
  }

  ll mlt = max(0LL, (n / k) - 2) ;
  ll dpk = dp[k];
  cout << (n >= k3 ? dpk * mlt + dp[n%k + 2*k] : dp[n]) << endl;

}
0