結果

問題 No.607 開通777年記念
ユーザー ThetaTheta
提出日時 2024-03-29 13:35:12
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 160 ms / 2,000 ms
コード長 761 bytes
コンパイル時間 342 ms
コンパイル使用メモリ 81,572 KB
実行使用メモリ 84,724 KB
最終ジャッジ日時 2024-03-29 13:35:15
合計ジャッジ時間 2,324 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,460 KB
testcase_01 AC 37 ms
53,460 KB
testcase_02 AC 38 ms
53,460 KB
testcase_03 AC 38 ms
53,460 KB
testcase_04 AC 42 ms
53,460 KB
testcase_05 AC 38 ms
53,460 KB
testcase_06 AC 44 ms
53,460 KB
testcase_07 AC 74 ms
77,044 KB
testcase_08 AC 38 ms
53,460 KB
testcase_09 AC 47 ms
61,820 KB
testcase_10 AC 43 ms
59,468 KB
testcase_11 AC 160 ms
84,596 KB
testcase_12 AC 158 ms
84,724 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    N, M = map(int, input().split())
    passengers = [0] * N
    diffs = [list(map(int, input().split())) for _ in range(M)]
    for diff in diffs:

        for idx in range(N):
            passengers[idx] += diff[idx]
        left_idx = 0
        right_idx = 0
        passenger_sum = 0
        while left_idx < N:
            if passenger_sum < 777:
                if right_idx == N:
                    break
                passenger_sum += passengers[right_idx]
                right_idx += 1
            elif passenger_sum > 777:
                passenger_sum -= passengers[left_idx]
                left_idx += 1
            else:
                print("YES")
                return

    print("NO")


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