結果

問題 No.1673 Lamps on a line
ユーザー ああいいああいい
提出日時 2021-12-03 23:18:29
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 646 ms / 2,000 ms
コード長 360 bytes
コンパイル時間 443 ms
コンパイル使用メモリ 10,628 KB
実行使用メモリ 20,100 KB
最終ジャッジ日時 2023-09-20 11:20:13
合計ジャッジ時間 4,739 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,896 KB
testcase_01 AC 16 ms
7,828 KB
testcase_02 AC 216 ms
9,356 KB
testcase_03 AC 211 ms
9,252 KB
testcase_04 AC 368 ms
9,892 KB
testcase_05 AC 34 ms
8,596 KB
testcase_06 AC 320 ms
9,704 KB
testcase_07 AC 326 ms
15,368 KB
testcase_08 AC 22 ms
10,124 KB
testcase_09 AC 480 ms
15,420 KB
testcase_10 AC 497 ms
16,928 KB
testcase_11 AC 59 ms
10,872 KB
testcase_12 AC 646 ms
20,100 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,Q = list(map(int,input().split()))
L = [0] * Q
R = [0] * Q
for i in range(Q):
    L[i],R[i] = list(map(int,input().split()))
lamp = [0] * (N+1)
count = 0
for i in range(Q):
    for j in range(L[i],R[i] + 1):
        if lamp[j] == 1:
            count -= 1
            lamp[j] = 0
        else:
            count += 1
            lamp[j] = 1
    print(count)
0