結果

問題 No.607 開通777年記念
ユーザー mitsuomitsuo
提出日時 2017-12-31 21:04:18
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 829 ms / 2,000 ms
コード長 736 bytes
コンパイル時間 105 ms
コンパイル使用メモリ 10,996 KB
実行使用メモリ 12,908 KB
最終ジャッジ日時 2023-08-23 12:34:41
合計ジャッジ時間 2,593 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
7,812 KB
testcase_01 AC 16 ms
7,836 KB
testcase_02 AC 18 ms
7,776 KB
testcase_03 AC 14 ms
7,792 KB
testcase_04 AC 14 ms
7,776 KB
testcase_05 AC 15 ms
7,788 KB
testcase_06 AC 14 ms
7,868 KB
testcase_07 AC 34 ms
8,836 KB
testcase_08 AC 14 ms
7,828 KB
testcase_09 AC 23 ms
7,828 KB
testcase_10 AC 15 ms
8,272 KB
testcase_11 AC 749 ms
12,908 KB
testcase_12 AC 829 ms
12,328 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def check(l):
    s = 0
    e = 1
    for _ in range(0, 2 * len(l)):
        su = sum(l[s:e])
        if su == 777:
            return True
        elif su > 777:
            s += 1
        elif su < 777:
            e += 1
        if s == e and e >= len(l):
            return False
    return False


def solve(N, M, data):
    train = [0 for _ in range(0, N)]
    for d in data:
        di = [int(k) for k in d.split(" ")]
        train = [t + d for t, d in zip(train, di)]
        if sum(train) >=  777:
            if check(train):
                return "YES"
    return "NO"

if __name__ == '__main__':
    N, M = map(int, input().split())
    d = []
    for _ in range(0, M):
        d.append(input())
    print(solve(N, M, d))
0