結果

問題 No.1948 足し算するだけのパズルゲーム(1)
ユーザー AkariAkari
提出日時 2022-05-21 00:03:35
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 1,656 ms / 2,000 ms
コード長 981 bytes
コンパイル時間 611 ms
コンパイル使用メモリ 11,844 KB
実行使用メモリ 71,468 KB
最終ジャッジ日時 2023-10-20 14:58:12
合計ジャッジ時間 33,589 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,623 ms
42,460 KB
testcase_01 AC 484 ms
42,564 KB
testcase_02 AC 471 ms
42,564 KB
testcase_03 AC 477 ms
42,560 KB
testcase_04 AC 480 ms
42,564 KB
testcase_05 AC 477 ms
42,560 KB
testcase_06 AC 477 ms
42,564 KB
testcase_07 AC 1,360 ms
46,436 KB
testcase_08 AC 1,046 ms
47,992 KB
testcase_09 AC 1,349 ms
47,992 KB
testcase_10 AC 1,656 ms
47,992 KB
testcase_11 AC 1,081 ms
47,972 KB
testcase_12 AC 1,160 ms
46,436 KB
testcase_13 AC 1,133 ms
46,436 KB
testcase_14 AC 1,120 ms
46,436 KB
testcase_15 AC 1,058 ms
46,436 KB
testcase_16 AC 483 ms
42,564 KB
testcase_17 AC 480 ms
42,564 KB
testcase_18 AC 487 ms
42,564 KB
testcase_19 AC 483 ms
42,564 KB
testcase_20 AC 1,635 ms
46,436 KB
testcase_21 AC 1,624 ms
46,436 KB
testcase_22 AC 1,065 ms
46,436 KB
testcase_23 AC 1,059 ms
46,436 KB
testcase_24 AC 1,633 ms
46,436 KB
testcase_25 AC 1,606 ms
47,164 KB
testcase_26 AC 1,645 ms
71,468 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import numpy as np



def main():
    h, w = map(int, input().split())
    A = np.fromstring(sys.stdin.read(), np.int64, sep=' ').reshape(-1, w)
    B = np.zeros_like(A, np.int64)
    C = np.zeros_like(A, np.int64)
    B[0, 0] = A[0, 0]
    for i in range(h):
        for j in range(w):
            if i == h - 1 and j == w - 1: continue
            a = A[i, j]
            if i:
                b = B[i - 1, j]
                c = C[i - 1, j]
                if b > a: B[i, j] = max(B[i, j], b + a)
                if c > a: C[i, j] = max(C[i, j], c + a)
                C[i, j] = max(C[i, j], b)
            if j:
                b = B[i, j - 1]
                c = C[i, j - 1]
                if b > a: B[i, j] = max(B[i, j], b + a)
                if c > a: C[i, j] = max(C[i, j], c + a)
                C[i, j] = max(C[i, j], b)
    print('Yes' if max(B[-2, -1], B[-1, -2], C[-2, -1], C[-1, -2]) > A[-1, -1] else 'No')

    



if __name__ == '__main__':
    main()
0