結果

問題 No.158 奇妙なお使い
ユーザー 0w10w1
提出日時 2020-07-13 02:35:04
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 34 ms / 5,000 ms
コード長 1,577 bytes
コンパイル時間 2,032 ms
コンパイル使用メモリ 199,628 KB
実行使用メモリ 47,016 KB
最終ジャッジ日時 2023-08-06 11:35:39
合計ジャッジ時間 4,577 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 23 ms
46,808 KB
testcase_01 AC 26 ms
46,836 KB
testcase_02 AC 20 ms
46,676 KB
testcase_03 AC 28 ms
46,660 KB
testcase_04 AC 34 ms
46,884 KB
testcase_05 AC 14 ms
46,848 KB
testcase_06 AC 30 ms
46,760 KB
testcase_07 AC 13 ms
46,668 KB
testcase_08 AC 25 ms
46,676 KB
testcase_09 AC 28 ms
46,768 KB
testcase_10 AC 28 ms
46,764 KB
testcase_11 AC 29 ms
46,788 KB
testcase_12 AC 26 ms
46,816 KB
testcase_13 AC 27 ms
46,768 KB
testcase_14 AC 29 ms
46,768 KB
testcase_15 AC 30 ms
46,820 KB
testcase_16 AC 28 ms
46,768 KB
testcase_17 AC 29 ms
46,968 KB
testcase_18 AC 27 ms
46,832 KB
testcase_19 AC 29 ms
46,884 KB
testcase_20 AC 29 ms
46,772 KB
testcase_21 AC 29 ms
46,668 KB
testcase_22 AC 29 ms
46,680 KB
testcase_23 AC 29 ms
46,668 KB
testcase_24 AC 29 ms
46,844 KB
testcase_25 AC 29 ms
46,676 KB
testcase_26 AC 25 ms
46,728 KB
testcase_27 AC 27 ms
46,664 KB
testcase_28 AC 28 ms
46,884 KB
testcase_29 AC 26 ms
47,016 KB
testcase_30 AC 28 ms
46,672 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