結果

問題 No.1673 Lamps on a line
ユーザー c-yanc-yan
提出日時 2021-09-11 05:11:56
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 466 ms / 2,000 ms
コード長 384 bytes
コンパイル時間 88 ms
コンパイル使用メモリ 10,540 KB
実行使用メモリ 15,720 KB
最終ジャッジ日時 2023-09-04 04:21:13
合計ジャッジ時間 4,136 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,816 KB
testcase_01 AC 16 ms
7,820 KB
testcase_02 AC 117 ms
9,936 KB
testcase_03 AC 117 ms
9,960 KB
testcase_04 AC 197 ms
11,380 KB
testcase_05 AC 26 ms
8,604 KB
testcase_06 AC 176 ms
10,800 KB
testcase_07 AC 215 ms
14,776 KB
testcase_08 AC 21 ms
10,216 KB
testcase_09 AC 328 ms
14,356 KB
testcase_10 AC 336 ms
15,720 KB
testcase_11 AC 44 ms
10,760 KB
testcase_12 AC 466 ms
15,564 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