結果

問題 No.2390 Udon Coupon (Hard)
ユーザー GlinTFrauleinGlinTFraulein
提出日時 2023-06-15 00:28:39
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 924 bytes
コンパイル時間 5,753 ms
コンパイル使用メモリ 259,768 KB
実行使用メモリ 814,484 KB
最終ジャッジ日時 2023-09-26 08:00:43
合計ジャッジ時間 10,573 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 RE -
testcase_06 WA -
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 RE -
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 WA -
testcase_17 AC 5 ms
6,264 KB
testcase_18 AC 9 ms
10,372 KB
testcase_19 AC 7 ms
7,216 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
testcase_40 RE -
testcase_41 RE -
testcase_42 MLE -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
権限があれば一括ダウンロードができます

ソースコード

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-1) / k) - 2) % mod;
  ll dpk = dp[k] % mod;

  ll ans = (n >= k3 ? dpk * mlt + dp[n%k + 2*k] : dp[n]) % mod;
  
  cout << ans << endl;

}
0