結果
| 問題 |
No.102 トランプを奪え
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-02-02 15:57:30 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 418 ms / 5,000 ms |
| コード長 | 1,417 bytes |
| コンパイル時間 | 464 ms |
| コンパイル使用メモリ | 82,048 KB |
| 実行使用メモリ | 82,028 KB |
| 最終ジャッジ日時 | 2024-06-11 09:28:11 |
| 合計ジャッジ時間 | 3,207 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 8 |
ソースコード
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
A, B, C, D = sorted(map(int, input().split()), reverse=True)
DP = [[[[[None]*(A-a+B-b+C-c+D-d+1) for d in range(min(D, c)+1)]
for c in range(min(C, b)+1)] for b in range(min(B, a)+1)] for a in range(A+1)]
tot = A+B+C+D
def solve(a, b, c, d, e):
if a == b == c == d == 0:
return e
a, b, c, d = sorted([a, b, c, d], reverse=True)
if DP[a][b][c][d][e] is not None:
return DP[a][b][c][d][e]
opp = (A-a+B-b+C-c+D-d)-e
ans = 0
for i in range(1, min(3, a)+1):
ans = max(ans, tot-solve(a-i, b, c, d,
opp if a != i else opp // 2))
for i in range(1, min(3, b)+1):
ans = max(ans, tot-solve(a, b-i, c, d,
opp if b != i else opp // 2))
for i in range(1, min(3, c)+1):
ans = max(ans, tot-solve(a, b, c-i, d,
opp if c != i else opp // 2))
for i in range(1, min(3, d)+1):
ans = max(ans, tot-solve(a, b, c, d-i,
opp if d != i else opp // 2))
DP[a][b][c][d][e] = ans
return ans
ans = solve(A, B, C, D, 0)
if ans > tot-ans:
print('Taro')
elif ans == tot-ans:
print('Draw')
else:
print('Jiro')
if __name__ == '__main__':
main()