結果

問題 No.158 奇妙なお使い
ユーザー yaoshimaxyaoshimax
提出日時 2015-03-01 14:55:06
言語 PyPy2
(7.3.15)
結果
AC  
実行時間 2,304 ms / 5,000 ms
コード長 1,568 bytes
コンパイル時間 1,608 ms
コンパイル使用メモリ 77,428 KB
実行使用メモリ 177,932 KB
最終ジャッジ日時 2023-09-11 07:59:38
合計ジャッジ時間 16,082 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 336 ms
176,968 KB
testcase_01 AC 410 ms
177,904 KB
testcase_02 AC 292 ms
176,308 KB
testcase_03 AC 328 ms
175,976 KB
testcase_04 AC 2,304 ms
177,636 KB
testcase_05 AC 223 ms
165,048 KB
testcase_06 AC 333 ms
175,924 KB
testcase_07 AC 226 ms
165,128 KB
testcase_08 AC 315 ms
176,104 KB
testcase_09 AC 373 ms
177,468 KB
testcase_10 AC 377 ms
177,064 KB
testcase_11 AC 377 ms
176,708 KB
testcase_12 AC 325 ms
176,176 KB
testcase_13 AC 322 ms
176,156 KB
testcase_14 AC 417 ms
177,192 KB
testcase_15 AC 454 ms
177,932 KB
testcase_16 AC 460 ms
177,300 KB
testcase_17 AC 580 ms
177,584 KB
testcase_18 AC 369 ms
176,944 KB
testcase_19 AC 362 ms
176,612 KB
testcase_20 AC 386 ms
176,924 KB
testcase_21 AC 343 ms
175,924 KB
testcase_22 AC 339 ms
175,948 KB
testcase_23 AC 396 ms
177,352 KB
testcase_24 AC 386 ms
176,896 KB
testcase_25 AC 333 ms
176,028 KB
testcase_26 AC 399 ms
177,684 KB
testcase_27 AC 331 ms
176,304 KB
testcase_28 AC 494 ms
177,608 KB
testcase_29 AC 332 ms
176,440 KB
testcase_30 AC 508 ms
177,472 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

A1000,A100,A1=map(int,raw_input().split())
Db =int(raw_input())
B1000,B100,B1=map(int,raw_input().split())
Dc = int(raw_input())
C1000,C100,C1=map(int,raw_input().split())

dp = [[[-1 for i in xrange(101)] for j in xrange(11)] for k in xrange(10001)]
dp[A1000*1000+A100*100+A1][A1000][A100]=0
ans = 0
for tot in range(A1000*1000+A100*100+A1,-1,-1):
    for At in range(11):
        for Ah in range(101):
            Ao = tot-At*1000-Ah*100
            dist = dp[tot][At][Ah]
            if dist < 0:
                continue
            ans = max(ans,dist)
            for at in range(min(At,Db/1000)+1):
                for ah in range( max(0,(Db-at*1000-Ao+99)/100), min(Ah,max(0,(Db-at*1000)/100))+1):
                    ao=Db-at*1000-ah*100
                    if at > At or ah > Ah or ao > Ao:
                        print at,At,ah,Ah,ao,Ao
                    #print "see",At-at+B1000,Ah-ah+B100,Ao-ao+B1
                    Nt,Nh,No = At-at+B1000, Ah-ah+B100,Ao-ao+B1
                    Ntot = Nt*1000+Nh*100+No
                    dp[Ntot][Nt][Nh] = max(dp[Ntot][Nt][Nh],dist+1)
            for at in range(min(At,Dc/1000)+1):
                for ah in range( max(0,(Dc-at*1000-Ao+99)/100), min(Ah,max(0,(Dc-at*1000)/100))+1):
                    ao=Dc-at*1000-ah*100
                    if at > At or ah > Ah or ao > Ao:
                        print at,At,ah,Ah,ao,Ao
                    Nt,Nh,No = At-at+C1000, Ah-ah+C100,Ao-ao+C1
                    Ntot = Nt*1000+Nh*100+No
                    dp[Ntot][Nt][Nh] = max(dp[Ntot][Nt][Nh],dist+1)
print ans
0