結果

問題 No.1673 Lamps on a line
ユーザー jamesjames
提出日時 2021-09-10 22:00:43
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 937 ms / 2,000 ms
コード長 297 bytes
コンパイル時間 300 ms
コンパイル使用メモリ 10,672 KB
実行使用メモリ 11,916 KB
最終ジャッジ日時 2023-09-02 17:33:29
合計ジャッジ時間 6,186 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,812 KB
testcase_01 AC 16 ms
7,800 KB
testcase_02 AC 347 ms
7,800 KB
testcase_03 AC 340 ms
7,804 KB
testcase_04 AC 595 ms
7,776 KB
testcase_05 AC 44 ms
7,804 KB
testcase_06 AC 503 ms
7,800 KB
testcase_07 AC 477 ms
10,820 KB
testcase_08 AC 23 ms
10,152 KB
testcase_09 AC 698 ms
8,476 KB
testcase_10 AC 716 ms
9,868 KB
testcase_11 AC 78 ms
10,076 KB
testcase_12 AC 937 ms
11,916 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,Q = map(int,input().split())
lamp = [0] * N

count = 0
for i in range(Q):
    Li,Ri = map(int,input().split())
    for j in range(Li,Ri+1):
        if lamp[j-1] == 0:
            lamp[j-1] = 1
            count += 1
        else:
            lamp[j-1] = 0
            count -= 1
    print(count)
0