結果

問題 No.158 奇妙なお使い
ユーザー しらっ亭しらっ亭
提出日時 2016-03-15 00:43:10
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 493 ms / 5,000 ms
コード長 1,484 bytes
コンパイル時間 1,364 ms
コンパイル使用メモリ 144,404 KB
実行使用メモリ 47,640 KB
最終ジャッジ日時 2023-09-11 23:53:22
合計ジャッジ時間 3,636 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
47,076 KB
testcase_01 AC 15 ms
46,748 KB
testcase_02 AC 12 ms
46,736 KB
testcase_03 AC 12 ms
46,736 KB
testcase_04 AC 493 ms
47,516 KB
testcase_05 AC 12 ms
46,872 KB
testcase_06 AC 12 ms
46,788 KB
testcase_07 AC 12 ms
46,808 KB
testcase_08 AC 11 ms
46,736 KB
testcase_09 AC 12 ms
46,764 KB
testcase_10 AC 12 ms
47,080 KB
testcase_11 AC 13 ms
46,808 KB
testcase_12 AC 12 ms
47,068 KB
testcase_13 AC 13 ms
46,744 KB
testcase_14 AC 13 ms
46,772 KB
testcase_15 AC 21 ms
46,948 KB
testcase_16 AC 19 ms
47,088 KB
testcase_17 AC 60 ms
46,808 KB
testcase_18 AC 17 ms
46,984 KB
testcase_19 AC 12 ms
46,748 KB
testcase_20 AC 14 ms
46,780 KB
testcase_21 AC 13 ms
47,084 KB
testcase_22 AC 13 ms
47,640 KB
testcase_23 AC 13 ms
46,788 KB
testcase_24 AC 12 ms
46,764 KB
testcase_25 AC 12 ms
46,832 KB
testcase_26 AC 14 ms
46,772 KB
testcase_27 AC 12 ms
46,812 KB
testcase_28 AC 34 ms
47,016 KB
testcase_29 AC 12 ms
47,080 KB
testcase_30 AC 37 ms
46,780 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FORR(x,arr) for(auto&& x:arr)
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); i--)
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i,n) for (int i = (n)-1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define BIT(n) (1LL<<(n))
#define SZ(x) ((int)(x).size())
typedef long long ll;
// -------------------------------------

int A1000, A100, A1;
int Db;
int B1000, B100, B1;
int Dc;
int C1000, C100, C1;

int dp[11][101][10001];

template<class T> inline bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }

int dfs(int a3, int a2, int a0) {
  if (dp[a3][a2][a0] != -1) return dp[a3][a2][a0];
  int ret = 0;

  REP(i, a3+1) REP(j, a2+1) {
    int ij = i * 1000 + j * 100;
    if (ij <= Db && a0 >= Db - ij)
      amax(ret, dfs(a3-i+B1000, a2-j+B100, a0-(Db-ij)+B1) + 1);
    if (ij <= Dc && a0 >= Dc - ij)
      amax(ret, dfs(a3-i+C1000, a2-j+C100, a0-(Dc-ij)+C1) + 1);
  }

  return dp[a3][a2][a0] = ret;
}

int main() {
  cin >> A1000 >> A100 >> A1;
  cin >> Db;
  cin >> B1000 >> B100 >> B1;
  cin >> Dc;
  cin >> C1000 >> C100 >> C1;

  memset(dp, 0xff, sizeof(dp));

  ll ans = dfs(A1000, A100, A1);

  cout << ans << endl;

  return 0;
}
0