結果

問題 No.158 奇妙なお使い
ユーザー h_nosonh_noson
提出日時 2016-03-26 16:05:51
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 18 ms / 5,000 ms
コード長 1,227 bytes
コンパイル時間 574 ms
コンパイル使用メモリ 61,688 KB
実行使用メモリ 8,124 KB
最終ジャッジ日時 2023-09-11 23:56:23
合計ジャッジ時間 2,016 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 18 ms
8,124 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 3 ms
4,984 KB
testcase_15 AC 4 ms
4,732 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 5 ms
6,088 KB
testcase_18 AC 6 ms
5,696 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 3 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 3 ms
4,376 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

#define RREP(i,s,e) for (i = s; i >= e; i--)
#define rrep(i,n) RREP(i,n,0)
#define REP(i,s,e) for (i = s; i < e; i++)
#define rep(i,n) REP(i,0,n)
#define INF 100000000

typedef long long ll;

int dp[11][101][10001];
bool used[11][101][100001];
int a[3], b[3], c[3];
int db, dc;

int count(int x, int y, int z) {
    if (used[x][y][z])
        return dp[x][y][z];
    used[x][y][z] = true;
    if (db <= x*1000+y*100+z && db%100<=z && db%1000<=y*100+z) {
        int nx = min(x,db/1000);
        int ny = min(y,(db-nx*1000)/100);
        int nz = min(z,db-nx*1000-ny*100);
        dp[x][y][z] = max(dp[x][y][z],count(x-nx+b[0],y-ny+b[1],z-nz+b[2])+1);
    }
    if (dc <= x*1000+y*100+z && dc%100<=z && dc%1000<=y*100+z) {
        int nx = min(x,dc/1000);
        int ny = min(y,(dc-nx*1000)/100);
        int nz = min(z,dc-nx*1000-ny*100);
        dp[x][y][z] = max(dp[x][y][z],count(x-nx+c[0],y-ny+c[1],z-nz+c[2])+1);
    }
    return dp[x][y][z];
}

int main() {
    int i;
    rep (i,3) cin >> a[i];
    cin >> db;
    rep (i,3) cin >> b[i];
    cin >> dc;
    rep (i,3) cin >> c[i];
    cout << count(a[0],a[1],a[2]) << endl;
    return 0;
}
0