結果

問題 No.158 奇妙なお使い
ユーザー codershifthcodershifth
提出日時 2015-12-28 01:13:35
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 680 ms / 5,000 ms
コード長 1,337 bytes
コンパイル時間 1,272 ms
コンパイル使用メモリ 145,608 KB
実行使用メモリ 91,324 KB
最終ジャッジ日時 2023-09-11 22:56:19
合計ジャッジ時間 4,822 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
90,184 KB
testcase_01 AC 31 ms
90,240 KB
testcase_02 AC 28 ms
90,164 KB
testcase_03 AC 28 ms
90,364 KB
testcase_04 AC 680 ms
91,324 KB
testcase_05 AC 28 ms
90,156 KB
testcase_06 AC 28 ms
90,164 KB
testcase_07 AC 28 ms
90,156 KB
testcase_08 AC 28 ms
90,192 KB
testcase_09 AC 28 ms
90,172 KB
testcase_10 AC 29 ms
90,368 KB
testcase_11 AC 28 ms
90,304 KB
testcase_12 AC 28 ms
90,240 KB
testcase_13 AC 28 ms
90,164 KB
testcase_14 AC 29 ms
90,240 KB
testcase_15 AC 39 ms
90,260 KB
testcase_16 AC 36 ms
90,400 KB
testcase_17 AC 89 ms
90,264 KB
testcase_18 AC 35 ms
90,332 KB
testcase_19 AC 28 ms
90,264 KB
testcase_20 AC 32 ms
90,432 KB
testcase_21 AC 28 ms
90,576 KB
testcase_22 AC 29 ms
91,280 KB
testcase_23 AC 29 ms
90,380 KB
testcase_24 AC 28 ms
90,432 KB
testcase_25 AC 28 ms
90,160 KB
testcase_26 AC 30 ms
90,208 KB
testcase_27 AC 27 ms
90,224 KB
testcase_28 AC 57 ms
90,228 KB
testcase_29 AC 28 ms
90,252 KB
testcase_30 AC 58 ms
90,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int (i)=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define RANGE(vec) (vec).begin(),(vec).end()

using namespace std;

array<int,3> A,B,C;
int Db,Dc;
ll dp[11][101][10001];

class StrangeErrand {
public:
    ll calc(int a, int b, int c) {
        if (dp[a][b][c] >= 0)
            return dp[a][b][c];
        ll maxCnt = 0;
        REP(i,a+1)
        REP(j,b+1)
        {
            int restDb = Db - i*1000 - j*100;
            int restDc = Dc - i*1000 - j*100;

            if (restDb >= 0 && restDb <= c)
                maxCnt = max(calc(a-i+B[0],b-j+B[1],c-restDb+B[2])+1, maxCnt);
            if (restDc >= 0 && restDc <= c)
                maxCnt = max(calc(a-i+C[0],b-j+C[1],c-restDc+C[2])+1, maxCnt);
        }
        return dp[a][b][c] = maxCnt;
    }
    void solve(void) {
        REP(i,3) cin>>A[i];
        cin>>Db;
        REP(i,3) cin>>B[i];
        cin>>Dc;
        REP(i,3) cin>>C[i];

        REP(i,11)
        REP(j,101)
        REP(k,10001)
            dp[i][j][k] = -1;
        cout<<calc(A[0],A[1],A[2])<<endl;
    }
};

#if 1
int main(int argc, char *argv[])
{
        ios::sync_with_stdio(false);
        auto obj = new StrangeErrand();
        obj->solve();
        delete obj;
        return 0;
}
#endif
0