結果

問題 No.158 奇妙なお使い
ユーザー yaoshimaxyaoshimax
提出日時 2015-03-01 14:39:22
言語 PyPy2
(7.3.15)
結果
WA  
実行時間 -
コード長 1,617 bytes
コンパイル時間 1,085 ms
コンパイル使用メモリ 77,304 KB
実行使用メモリ 188,840 KB
最終ジャッジ日時 2023-09-06 05:51:33
合計ジャッジ時間 12,185 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 248 ms
168,440 KB
testcase_01 AC 277 ms
168,516 KB
testcase_02 WA -
testcase_03 AC 178 ms
158,540 KB
testcase_04 AC 1,849 ms
188,840 KB
testcase_05 AC 171 ms
158,600 KB
testcase_06 AC 169 ms
158,520 KB
testcase_07 AC 170 ms
158,340 KB
testcase_08 AC 173 ms
158,568 KB
testcase_09 AC 231 ms
168,140 KB
testcase_10 AC 267 ms
168,664 KB
testcase_11 AC 280 ms
169,424 KB
testcase_12 AC 181 ms
158,432 KB
testcase_13 AC 178 ms
158,352 KB
testcase_14 AC 309 ms
169,604 KB
testcase_15 AC 344 ms
169,560 KB
testcase_16 AC 315 ms
169,052 KB
testcase_17 WA -
testcase_18 AC 283 ms
168,512 KB
testcase_19 AC 228 ms
167,788 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 172 ms
158,536 KB
testcase_26 AC 306 ms
169,856 KB
testcase_27 AC 183 ms
158,852 KB
testcase_28 AC 417 ms
171,332 KB
testcase_29 AC 197 ms
159,620 KB
testcase_30 AC 406 ms
170,496 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from Queue import Queue
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(10001)] for j in xrange(101)] for k in xrange(11)]
best = [(-1,-1,-1) for i in xrange(10001)]
q = Queue()
dp[A1000][A100][A1]=0
ans = 0
q.put((0,A1000,A100,A1))
while q.empty()==False:
    dist,At,Ah,Ao = q.get()
    ans = max(ans,dist)
    price = At*1000+Ah*100+Ao*1
    bt,bh,bo=best[price]
    if bt != -1 and ((bt==At and bh >= Ah) or (bh==Ah and bt>At) or (bo==Ao and bt>At)) :
        continue
    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
            if dp[At-at+B1000][Ah-ah+B100][Ao-ao+B1]==-1:
                dp[At-at+B1000][Ah-ah+B100][Ao-ao+B1]=dist+1
                q.put((dist+1,At-at+B1000,Ah-ah+B100,Ao-ao+B1))
    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
            #print "see",At-at+C1000,Ah-ah+C100,Ao-ao+C1
            if dp[At-at+C1000][Ah-ah+C100][Ao-ao+C1]==-1:
                dp[At-at+C1000][Ah-ah+C100][Ao-ao+C1]=dist+1
                q.put((dist+1,At-at+C1000,Ah-ah+C100,Ao-ao+C1))
print ans
0