結果

問題 No.158 奇妙なお使い
ユーザー parukiparuki
提出日時 2016-09-06 10:36:01
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 28 ms / 5,000 ms
コード長 1,331 bytes
コンパイル時間 1,515 ms
コンパイル使用メモリ 164,624 KB
実行使用メモリ 47,924 KB
最終ジャッジ日時 2023-09-12 04:32:12
合計ジャッジ時間 3,857 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
46,764 KB
testcase_01 AC 13 ms
46,796 KB
testcase_02 AC 13 ms
46,740 KB
testcase_03 AC 13 ms
46,736 KB
testcase_04 AC 28 ms
47,924 KB
testcase_05 AC 13 ms
46,832 KB
testcase_06 AC 14 ms
46,728 KB
testcase_07 AC 14 ms
46,760 KB
testcase_08 AC 14 ms
46,772 KB
testcase_09 AC 14 ms
46,776 KB
testcase_10 AC 14 ms
46,732 KB
testcase_11 AC 13 ms
46,740 KB
testcase_12 AC 13 ms
46,784 KB
testcase_13 AC 14 ms
46,724 KB
testcase_14 AC 14 ms
46,920 KB
testcase_15 AC 13 ms
46,940 KB
testcase_16 AC 14 ms
46,776 KB
testcase_17 AC 14 ms
46,876 KB
testcase_18 AC 15 ms
46,876 KB
testcase_19 AC 14 ms
46,768 KB
testcase_20 AC 13 ms
46,804 KB
testcase_21 AC 13 ms
47,344 KB
testcase_22 AC 14 ms
47,852 KB
testcase_23 AC 13 ms
46,740 KB
testcase_24 AC 13 ms
46,764 KB
testcase_25 AC 13 ms
46,732 KB
testcase_26 AC 13 ms
46,768 KB
testcase_27 AC 14 ms
46,764 KB
testcase_28 AC 14 ms
46,932 KB
testcase_29 AC 13 ms
46,776 KB
testcase_30 AC 13 ms
47,092 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

int D[2], BC[2][3], dp[11][101][10001];

int f(int a, int b, int c){
    int &x = dp[a][b][c];
    if(x != -1)return x;
    x = 0;
    int sm = a*1000 + b*100 + c;
    rep(i, 2)if(sm >= D[i]){
        int aa = a, bb = b, cc = c, y, s = D[i];
        y = min(s / 1000, a);
        aa -= y;
        s -= y * 1000;
        y = min(s / 100, b);
        bb -= y;
        s -= y * 100;
        y = min(s, c);
        cc -= y;
        s -= y;
        if(s == 0){
            aa += BC[i][0];
            bb += BC[i][1];
            cc += BC[i][2];
            smax(x, f(aa, bb, cc) + 1);
        }
    }
    return x;
}

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    
    rep(i, 2){
        cin >> D[i];
        rep(j, 3)cin >> BC[i][j];
    }
    
    MEM(dp, -1);
    int ans = f(a, b, c);
    cout << ans << endl;
}
0