結果

問題 No.158 奇妙なお使い
ユーザー motimoti
提出日時 2015-04-13 18:41:30
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 839 bytes
コンパイル時間 350 ms
コンパイル使用メモリ 51,780 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-17 20:00:22
合計ジャッジ時間 1,460 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 2 ms
4,380 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>

using namespace std;

int kDebt[2], e1000[2], e100[2], e1[2];

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

int solve(int const kA1000, int const kA100, int const kA1) {
  int& ret = dp[kA1000][kA100][kA1];
  if(ret >= 0) return ret;
  ret = 0;
  
  for(int i=0;i<2;i++) {
    int a1000 = kA1000, a100 = kA1000, a1 = kA1;
    int debt = kDebt[i];
    while(a1000 > 0 && debt >= 1000) { a1000--, debt-=1000; }
    while(a100  > 0 && debt >= 100)  { a100--,  debt-=100;  }
    if(a1 >= debt) { a1 -= debt, debt = 0; }
    if(debt == 0) {
      ret = max(ret, 1+solve(a1000+e1000[i], a100+e100[i], a1+e1[i]));
    }
  }

  return ret;
}

int main() {

  int a1000, a100, a1;
  cin >> a1000 >> a100 >> a1;
  for(int i=0;i<2;i++)
    cin >> kDebt[i] >> e1000[i] >> e100[i] >> e1[i];

  cout << solve(a1000, a100, a1) << endl;
  
  return 0;
}
0