結果

問題 No.1673 Lamps on a line
ユーザー weakenweaken
提出日時 2021-09-27 12:08:38
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 775 ms / 2,000 ms
コード長 459 bytes
コンパイル時間 100 ms
コンパイル使用メモリ 10,724 KB
実行使用メモリ 11,904 KB
最終ジャッジ日時 2023-09-20 12:19:37
合計ジャッジ時間 5,371 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,776 KB
testcase_01 AC 17 ms
7,796 KB
testcase_02 AC 315 ms
7,776 KB
testcase_03 AC 312 ms
7,768 KB
testcase_04 AC 527 ms
7,844 KB
testcase_05 AC 41 ms
7,864 KB
testcase_06 AC 454 ms
7,840 KB
testcase_07 AC 409 ms
10,728 KB
testcase_08 AC 22 ms
10,132 KB
testcase_09 AC 607 ms
8,444 KB
testcase_10 AC 627 ms
9,976 KB
testcase_11 AC 68 ms
10,068 KB
testcase_12 AC 775 ms
11,904 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def toggle(on: int) -> int:
    return 1 - on


def main():
    n, q = map(int, input().split())

    cnt = 0
    lamps = [0] * n
    for _ in range(q):
        l, r = map(int, input().split())
        for i in range(l, r + 1):
            on_off = toggle(lamps[i - 1])
            if on_off == 0:
                cnt -= 1
            else:
                cnt += 1
            lamps[i - 1] = on_off
        print(cnt)


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