結果

問題 No.561 東京と京都
ユーザー naimonon77naimonon77
提出日時 2018-02-12 19:45:39
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 637 bytes
コンパイル時間 94 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 11,264 KB
最終ジャッジ日時 2024-05-03 20:42:22
合計ジャッジ時間 1,508 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,880 KB
testcase_01 AC 33 ms
10,880 KB
testcase_02 AC 32 ms
11,136 KB
testcase_03 AC 33 ms
11,008 KB
testcase_04 AC 29 ms
11,136 KB
testcase_05 AC 30 ms
11,008 KB
testcase_06 AC 29 ms
11,008 KB
testcase_07 AC 29 ms
11,008 KB
testcase_08 AC 29 ms
11,136 KB
testcase_09 AC 29 ms
11,008 KB
testcase_10 AC 30 ms
11,136 KB
testcase_11 WA -
testcase_12 AC 32 ms
11,008 KB
testcase_13 AC 30 ms
11,136 KB
testcase_14 AC 28 ms
11,136 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 29 ms
11,136 KB
testcase_20 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import random

def does_change(cur_place, cur_day):
    if (money[cur_day][cur_place] >= money[cur_day][not cur_place]):
         return False
    a = 0
    b = - 2 * D
    for i in range(cur_day, N):
        a += money[i][cur_place]
        b += money[i][not cur_place]
        if (a < b): return True
    if (a < b + D): return True
    else: return False

N, D = map(int, input().split())
money = [list(map(int, input().split())) for i in range(N)]

cur_place = 0
cur_v = 0
for i in range(N):
    if (does_change(cur_place, i)):
        cur_place = not cur_place
        cur_v -= D
    cur_v += money[i][cur_place]

print(cur_v)





0