結果

問題 No.1673 Lamps on a line
ユーザー shinichishinichi
提出日時 2021-09-11 11:48:13
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 330 ms / 2,000 ms
コード長 278 bytes
コンパイル時間 643 ms
コンパイル使用メモリ 87,084 KB
実行使用メモリ 81,156 KB
最終ジャッジ日時 2023-09-04 22:00:21
合計ジャッジ時間 5,258 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
70,928 KB
testcase_01 AC 74 ms
70,996 KB
testcase_02 AC 256 ms
77,620 KB
testcase_03 AC 254 ms
78,624 KB
testcase_04 AC 330 ms
77,348 KB
testcase_05 AC 124 ms
77,804 KB
testcase_06 AC 288 ms
77,140 KB
testcase_07 AC 237 ms
80,092 KB
testcase_08 AC 98 ms
78,608 KB
testcase_09 AC 297 ms
77,296 KB
testcase_10 AC 311 ms
78,904 KB
testcase_11 AC 119 ms
79,348 KB
testcase_12 AC 315 ms
81,156 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, Q = map(int, input().split())

now = 0
lamp = [0] * (N+1)
for _ in range(Q):
    l, r = map(lambda x: int(x)-1, input().split())
    for i in range(l, r+1):
        if lamp[i]:
            now -= 1
        else:
            now += 1
        lamp[i] = 1-lamp[i]
    print(now)
0