結果

問題 No.158 奇妙なお使い
ユーザー parukiparuki
提出日時 2016-09-06 09:48:09
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 375 ms / 5,000 ms
コード長 1,279 bytes
コンパイル時間 1,529 ms
コンパイル使用メモリ 165,784 KB
実行使用メモリ 47,868 KB
最終ジャッジ日時 2023-09-12 04:32:18
合計ジャッジ時間 3,741 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
46,728 KB
testcase_01 AC 15 ms
46,760 KB
testcase_02 AC 13 ms
46,780 KB
testcase_03 AC 13 ms
46,736 KB
testcase_04 AC 375 ms
47,868 KB
testcase_05 AC 14 ms
46,728 KB
testcase_06 AC 13 ms
46,780 KB
testcase_07 AC 13 ms
46,776 KB
testcase_08 AC 13 ms
46,724 KB
testcase_09 AC 13 ms
46,848 KB
testcase_10 AC 14 ms
46,936 KB
testcase_11 AC 13 ms
46,788 KB
testcase_12 AC 14 ms
46,748 KB
testcase_13 AC 14 ms
46,768 KB
testcase_14 AC 15 ms
46,784 KB
testcase_15 AC 20 ms
46,784 KB
testcase_16 AC 18 ms
46,804 KB
testcase_17 AC 46 ms
46,748 KB
testcase_18 AC 18 ms
46,920 KB
testcase_19 AC 14 ms
46,788 KB
testcase_20 AC 15 ms
46,936 KB
testcase_21 AC 14 ms
47,132 KB
testcase_22 AC 15 ms
47,820 KB
testcase_23 AC 14 ms
46,744 KB
testcase_24 AC 13 ms
46,772 KB
testcase_25 AC 13 ms
46,740 KB
testcase_26 AC 16 ms
46,736 KB
testcase_27 AC 14 ms
46,784 KB
testcase_28 AC 35 ms
46,772 KB
testcase_29 AC 14 ms
46,784 KB
testcase_30 AC 37 ms
46,788 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 s = a*1000 + b*100 + c;
    rep(i, 2)if(s >= D[i]){
        rep(aa, a + 1){
            if(aa * 1000 > D[i])break;
            FOR(bb, max(0, D[i] - aa * 1000 - c + 99) / 100, b + 1){
                if(aa * 1000 + bb*100 > D[i])break;
                int cc = D[i] - aa*1000 - bb*100;
                smax(x, f(a - aa + BC[i][0], b - bb + BC[i][1], c - cc + BC[i][2]) + 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