結果

問題 No.158 奇妙なお使い
ユーザー srjywrdnprktsrjywrdnprkt
提出日時 2022-12-25 18:18:38
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 48 ms / 5,000 ms
コード長 1,130 bytes
コンパイル時間 6,208 ms
コンパイル使用メモリ 109,636 KB
実行使用メモリ 51,168 KB
最終ジャッジ日時 2023-08-12 08:39:05
合計ジャッジ時間 11,654 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
50,628 KB
testcase_01 AC 36 ms
50,592 KB
testcase_02 AC 37 ms
50,636 KB
testcase_03 AC 37 ms
50,592 KB
testcase_04 AC 48 ms
51,168 KB
testcase_05 AC 37 ms
50,636 KB
testcase_06 AC 37 ms
50,628 KB
testcase_07 AC 37 ms
50,632 KB
testcase_08 AC 37 ms
50,664 KB
testcase_09 AC 37 ms
50,592 KB
testcase_10 AC 37 ms
50,640 KB
testcase_11 AC 38 ms
50,668 KB
testcase_12 AC 39 ms
50,648 KB
testcase_13 AC 38 ms
50,660 KB
testcase_14 AC 37 ms
50,664 KB
testcase_15 AC 38 ms
50,644 KB
testcase_16 AC 37 ms
50,640 KB
testcase_17 AC 38 ms
50,680 KB
testcase_18 AC 39 ms
50,756 KB
testcase_19 AC 37 ms
50,628 KB
testcase_20 AC 38 ms
50,644 KB
testcase_21 AC 37 ms
50,688 KB
testcase_22 AC 39 ms
51,164 KB
testcase_23 AC 39 ms
50,580 KB
testcase_24 AC 39 ms
50,680 KB
testcase_25 AC 38 ms
50,676 KB
testcase_26 AC 40 ms
50,684 KB
testcase_27 AC 38 ms
50,640 KB
testcase_28 AC 39 ms
50,640 KB
testcase_29 AC 38 ms
50,684 KB
testcase_30 AC 38 ms
50,640 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <numeric>
#include <deque>

using namespace std;

vector<vector<vector<int>>> ans;

int ax, ay, az, db, bx, by, bz, dc, cx, cy, cz;

tuple<int, int, int> g(int i, int j, int k, int d){
    int x, y, z;
    x = min(d / 1000, i);
    d -= x * 1000;
    y = min(d / 100, j);
    d -= y * 100;
    z = min(d , k);
    d -= z;
    if (d == 0) return make_tuple(x, y, z);
    else return make_tuple(-1, -1, -1);
}

int f(int i, int j, int k){
    if (i == 0 && j == 0 && k == 0) return 0;
    if (ans[i][j][k] != -1) return ans[i][j][k];
    int a, b, c, mx = 0;
    tie(a, b, c) = g(i, j, k, db);
    if (a != -1) mx = max(mx, f(i-a+bx, j-b+by, k-c+bz)+1);
    tie(a, b, c) = g(i, j, k, dc);
    if (a != -1) mx = max(mx, f(i-a+cx, j-b+cy, k-c+cz)+1);

    return ans[i][j][k] = mx;
}

int main(){

    cin >> ax >> ay >> az >> db >> bx >> by >> bz >> dc >> cx >> cy >> cz;
    ans.resize(11, vector(101, vector<int>(10001, -1)));

    cout << f(ax, ay, az) << endl;

    return 0;
}
0