結果

問題 No.1673 Lamps on a line
ユーザー hirakuhiraku
提出日時 2021-09-11 09:07:02
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 703 ms / 2,000 ms
コード長 389 bytes
コンパイル時間 107 ms
コンパイル使用メモリ 10,668 KB
実行使用メモリ 32,044 KB
最終ジャッジ日時 2023-09-04 16:14:16
合計ジャッジ時間 4,471 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
7,816 KB
testcase_01 AC 16 ms
7,848 KB
testcase_02 AC 211 ms
15,252 KB
testcase_03 AC 209 ms
15,264 KB
testcase_04 AC 380 ms
20,620 KB
testcase_05 AC 35 ms
9,140 KB
testcase_06 AC 326 ms
18,716 KB
testcase_07 AC 339 ms
22,304 KB
testcase_08 AC 24 ms
10,352 KB
testcase_09 AC 509 ms
25,624 KB
testcase_10 AC 531 ms
27,580 KB
testcase_11 AC 62 ms
11,816 KB
testcase_12 AC 703 ms
32,044 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# https://yukicoder.me/problems/no/1673
# No.1673 Lamps on a line

# LRの幅が狭いので都度見ていく

N, Q = map(int, input().split())
LR = [list(map(int, input().split())) for _ in range(Q)]

lamp = [0] * N
cnt = 0
for l, r in LR:
    for i in range(l - 1, r):
        if lamp[i] == 0:
            cnt += 1
        else:
            cnt -= 1
        lamp[i] ^= 1
    print(cnt)
0