結果

問題 No.158 奇妙なお使い
ユーザー 0w10w1
提出日時 2020-07-13 02:35:04
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 32 ms / 5,000 ms
コード長 1,577 bytes
コンパイル時間 2,252 ms
コンパイル使用メモリ 202,400 KB
実行使用メモリ 46,952 KB
最終ジャッジ日時 2024-11-06 14:43:04
合計ジャッジ時間 4,257 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
46,804 KB
testcase_01 AC 25 ms
46,740 KB
testcase_02 AC 19 ms
46,824 KB
testcase_03 AC 25 ms
46,952 KB
testcase_04 AC 32 ms
46,880 KB
testcase_05 AC 14 ms
46,924 KB
testcase_06 AC 27 ms
46,948 KB
testcase_07 AC 16 ms
46,856 KB
testcase_08 AC 24 ms
46,732 KB
testcase_09 AC 26 ms
46,800 KB
testcase_10 AC 28 ms
46,820 KB
testcase_11 AC 28 ms
46,848 KB
testcase_12 AC 25 ms
46,848 KB
testcase_13 AC 26 ms
46,848 KB
testcase_14 AC 28 ms
46,928 KB
testcase_15 AC 27 ms
46,836 KB
testcase_16 AC 29 ms
46,848 KB
testcase_17 AC 28 ms
46,908 KB
testcase_18 AC 26 ms
46,848 KB
testcase_19 AC 27 ms
46,848 KB
testcase_20 AC 28 ms
46,848 KB
testcase_21 AC 28 ms
46,848 KB
testcase_22 AC 28 ms
46,848 KB
testcase_23 AC 27 ms
46,848 KB
testcase_24 AC 26 ms
46,848 KB
testcase_25 AC 31 ms
46,848 KB
testcase_26 AC 26 ms
46,808 KB
testcase_27 AC 27 ms
46,700 KB
testcase_28 AC 25 ms
46,688 KB
testcase_29 AC 26 ms
46,800 KB
testcase_30 AC 26 ms
46,776 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