結果

問題 No.158 奇妙なお使い
ユーザー koba-e964koba-e964
提出日時 2015-06-20 15:57:05
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 855 ms / 5,000 ms
コード長 1,558 bytes
コンパイル時間 610 ms
コンパイル使用メモリ 87,308 KB
実行使用メモリ 47,916 KB
最終ジャッジ日時 2023-09-11 11:28:19
合計ジャッジ時間 3,651 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
46,756 KB
testcase_01 AC 22 ms
46,824 KB
testcase_02 AC 14 ms
46,908 KB
testcase_03 AC 14 ms
46,872 KB
testcase_04 AC 855 ms
47,916 KB
testcase_05 AC 14 ms
46,928 KB
testcase_06 AC 14 ms
46,796 KB
testcase_07 AC 14 ms
46,756 KB
testcase_08 AC 14 ms
46,796 KB
testcase_09 AC 15 ms
46,732 KB
testcase_10 AC 15 ms
46,852 KB
testcase_11 AC 14 ms
46,912 KB
testcase_12 AC 14 ms
46,836 KB
testcase_13 AC 14 ms
46,816 KB
testcase_14 AC 18 ms
46,840 KB
testcase_15 AC 23 ms
46,812 KB
testcase_16 AC 21 ms
46,808 KB
testcase_17 AC 65 ms
46,740 KB
testcase_18 AC 18 ms
47,012 KB
testcase_19 AC 15 ms
46,976 KB
testcase_20 AC 17 ms
46,928 KB
testcase_21 AC 15 ms
47,336 KB
testcase_22 AC 15 ms
47,892 KB
testcase_23 AC 15 ms
46,784 KB
testcase_24 AC 14 ms
46,864 KB
testcase_25 AC 14 ms
46,840 KB
testcase_26 AC 22 ms
46,808 KB
testcase_27 AC 14 ms
46,872 KB
testcase_28 AC 65 ms
46,848 KB
testcase_29 AC 15 ms
46,808 KB
testcase_30 AC 206 ms
46,852 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef pair<int, int> PI;
const double EPS=1e-9;


int dp[11][101][10010];
int a[3], db, dc, b[3], c[3];

int rec(int x, int y, int z) {
  if (x < 0 || x > 10 || y < 0 || y > 100 || z < 0 || z > 10000) {
    return 0;
  }
  int &ret = dp[x][y][z];
  if (ret >= 0) {
    return ret;
  }
  int ma = 0;
  REP(i, 0, db / 1000 + 1) {
    REP(j, 0, db / 100 - 10 * i + 1) {
      int r = db - 1000 * i - 100 * j;
      if (x >= i && y >= j && z >= r) {
	ma = max(ma, rec(x - i + b[0], y - j + b[1], z - r + b[2]) + 1);
      }
    }
  }
  REP(i, 0, dc / 1000 + 1) {
    REP(j, 0, dc / 100 - 10 * i + 1) {
      int r = dc - 1000 * i - 100 * j;
      if (x >= i && y >= j && z >= r) {
	ma = max(ma, rec(x - i + c[0], y - j + c[1], z - r + c[2]) + 1);
      }
    }
  }
  return ret = ma;
}

int main(void){
  REP(i, 0, 3) {
    cin >> a[i];
  }
  cin >> db;
  REP(i, 0, 3) {
    cin >> b[i];
  }
  cin >> dc;
  REP(i, 0, 3) {
    cin >> c[i];
  }
  memset(dp, -1, sizeof(dp));
  cout << rec(a[0], a[1], a[2]) << endl;
}
0