結果

問題 No.1673 Lamps on a line
ユーザー c-yanc-yan
提出日時 2021-09-10 22:37:52
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 464 ms / 2,000 ms
コード長 384 bytes
コンパイル時間 755 ms
コンパイル使用メモリ 10,632 KB
実行使用メモリ 15,804 KB
最終ジャッジ日時 2023-09-02 19:17:39
合計ジャッジ時間 3,642 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,764 KB
testcase_01 AC 15 ms
7,772 KB
testcase_02 AC 119 ms
10,032 KB
testcase_03 AC 112 ms
9,940 KB
testcase_04 AC 189 ms
11,184 KB
testcase_05 AC 26 ms
8,640 KB
testcase_06 AC 175 ms
10,824 KB
testcase_07 AC 214 ms
14,712 KB
testcase_08 AC 21 ms
10,128 KB
testcase_09 AC 312 ms
14,252 KB
testcase_10 AC 325 ms
15,804 KB
testcase_11 AC 44 ms
10,780 KB
testcase_12 AC 464 ms
15,512 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from sys import stdin

readline = stdin.readline

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

c = 0
t = [0] * (N + 1)
result = []
for _ in range(Q):
    L, R = map(int, readline().split())
    for i in range(L - 1, R):
        if t[i] == 0:
            c += 1
            t[i] = 1
        elif t[i] == 1:
            c -= 1
            t[i] = 0
    result.append(c)
print(*result, sep='\n')
0