結果

問題 No.2686 商品券の使い道
ユーザー 👑 emthrmemthrm
提出日時 2024-03-20 22:05:30
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,398 bytes
コンパイル時間 2,986 ms
コンパイル使用メモリ 249,388 KB
実行使用メモリ 10,004 KB
最終ジャッジ日時 2024-03-20 22:05:51
合計ジャッジ時間 20,261 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 1,335 ms
6,676 KB
testcase_12 AC 71 ms
6,676 KB
testcase_13 AC 1,760 ms
6,676 KB
testcase_14 AC 459 ms
6,676 KB
testcase_15 AC 214 ms
6,676 KB
testcase_16 AC 1,175 ms
6,676 KB
testcase_17 AC 142 ms
6,676 KB
testcase_18 AC 411 ms
6,676 KB
testcase_19 AC 453 ms
6,676 KB
testcase_20 AC 1,749 ms
6,676 KB
testcase_21 AC 1,642 ms
6,676 KB
testcase_22 AC 25 ms
6,676 KB
testcase_23 AC 7 ms
6,676 KB
testcase_24 AC 969 ms
6,676 KB
testcase_25 AC 10 ms
6,676 KB
testcase_26 AC 371 ms
6,676 KB
testcase_27 AC 1,362 ms
6,676 KB
testcase_28 AC 3 ms
6,676 KB
testcase_29 AC 57 ms
6,676 KB
testcase_30 TLE -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
evil_random20_1.txt -- -
evil_random20_2.txt -- -
evil_random20_3.txt -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr double EPS = 1e-8;
constexpr int MOD = 998244353;
// constexpr int MOD = 1000000007;
constexpr int DY4[]{1, 0, -1, 0}, DX4[]{0, -1, 0, 1};
constexpr int DY8[]{1, 1, 0, -1, -1, -1, 0, 1};
constexpr int DX8[]{0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U>
inline bool chmax(T& a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U>
inline bool chmin(T& a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int n, m, q; cin >> n >> m >> q;
  vector<int> a(n), b(n); REP(i, n) cin >> a[i] >> b[i];
  ll ans = 0;
  const auto dfs = [&](auto dfs, const int i, const int today, const int tomorrow, const ll value) -> void {
    if (i == n) {
      chmax(ans, value);
      return;
    }
    dfs(dfs, i + 1, today, tomorrow, value);
    if (today >= a[i]) dfs(dfs, i + 1, today - a[i], tomorrow, value + b[i]);
    if (tomorrow >= a[i]) dfs(dfs, i + 1, today, tomorrow - a[i], value + b[i]);
  };
  dfs(dfs, 0, m, q, 0);
  cout << ans << '\n';
  return 0;
}
0