結果

問題 No.158 奇妙なお使い
ユーザー 0w10w1
提出日時 2020-07-13 02:35:04
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 51 ms / 5,000 ms
コード長 1,577 bytes
コンパイル時間 2,212 ms
コンパイル使用メモリ 195,456 KB
実行使用メモリ 47,104 KB
最終ジャッジ日時 2024-04-24 07:27:09
合計ジャッジ時間 4,399 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
46,848 KB
testcase_01 AC 45 ms
46,976 KB
testcase_02 AC 39 ms
46,848 KB
testcase_03 AC 48 ms
46,848 KB
testcase_04 AC 51 ms
46,976 KB
testcase_05 AC 33 ms
46,848 KB
testcase_06 AC 49 ms
46,848 KB
testcase_07 AC 33 ms
46,848 KB
testcase_08 AC 44 ms
46,976 KB
testcase_09 AC 45 ms
46,976 KB
testcase_10 AC 45 ms
46,976 KB
testcase_11 AC 47 ms
46,976 KB
testcase_12 AC 45 ms
47,104 KB
testcase_13 AC 45 ms
46,976 KB
testcase_14 AC 46 ms
47,104 KB
testcase_15 AC 47 ms
46,848 KB
testcase_16 AC 46 ms
46,848 KB
testcase_17 AC 47 ms
46,848 KB
testcase_18 AC 45 ms
46,976 KB
testcase_19 AC 47 ms
46,976 KB
testcase_20 AC 47 ms
46,976 KB
testcase_21 AC 46 ms
46,976 KB
testcase_22 AC 47 ms
46,976 KB
testcase_23 AC 47 ms
46,976 KB
testcase_24 AC 47 ms
46,848 KB
testcase_25 AC 47 ms
46,848 KB
testcase_26 AC 45 ms
46,848 KB
testcase_27 AC 46 ms
46,976 KB
testcase_28 AC 46 ms
46,848 KB
testcase_29 AC 43 ms
46,976 KB
testcase_30 AC 45 ms
46,848 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
  int a0, a1, a2;
  cin >> a0 >> a1 >> a2;
  int db;
  cin >> db;
  int b0, b1, b2;
  cin >> b0 >> b1 >> b2;
  int dc;
  cin >> dc;
  int c0, c1, c2;
  cin >> c0 >> c1 >> c2;

  int ea = a0 * 1000 + a1 * 100 + a2;
  int eb = b0 * 1000 + b1 * 100 + b2;
  int ec = c0 * 1000 + c1 * 100 + c2;

  static int d[10001][11][101];
  memset(d, 0xff, sizeof(d));
  d[ea][a0][a1] = 0;
  int maxd = 0;
  for (int s = ea; s; --s) {
    for (int i = 0; i <= 10; ++i) {
      for (int j = 0; j <= 100; ++j) {
        if (d[s][i][j] < 0) continue;
        int k = s - i * 1000 - j * 100;
        if (k < 0) break;
        if (s >= db) {
          int x = min(i, db / 1000);
          int y = min(j, (db - x * 1000) / 100);
          int z = min(k, db - x * 1000 - y * 100);
          int m = x * 1000 + y * 100 + z;
          if (m == db) {
            d[s - m + eb][i - x + b0][j - y + b1] = max(d[s - m + eb][i - x + b0][j - y + b1], d[s][i][j] + 1);
            maxd = max(maxd, d[s - m + eb][i - x + b0][j - y + b1]);
          }
        }
        if (s >= dc) {
          int x = min(i, dc / 1000);
          int y = min(j, (dc - x * 1000) / 100);
          int z = min(k, dc - x * 1000 - y * 100);
          int m = x * 1000 + y * 100 + z;
          if (m == dc) {
            d[s - m + ec][i - x + c0][j - y + c1] = max(d[s - m + ec][i - x + c0][j - y + c1], d[s][i][j] + 1);
            maxd = max(maxd, d[s - m + ec][i - x + c0][j - y + c1]);
          }
        }
      }
    }
  }

  cout << maxd << endl;

  return 0;
}

0