結果

問題 No.2390 Udon Coupon (Hard)
ユーザー GlinTFraulein
提出日時 2023-06-15 00:51:39
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 902 bytes
コンパイル時間 4,032 ms
コンパイル使用メモリ 251,952 KB
最終ジャッジ日時 2025-02-14 02:47:13
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 RE * 1
other AC * 13 WA * 8 RE * 23 MLE * 3
権限があれば一括ダウンロードができます

ソースコード

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) % mod;
  ll dpk = dp[k] % mod;  
  cout << (n >= k3 ? dpk * mlt + dp[n%k + 2*k] : dp[n]) % mod << endl;

}
0