結果

問題 No.1673 Lamps on a line
ユーザー mahiro72mahiro72
提出日時 2021-10-03 02:16:41
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 740 ms / 2,000 ms
コード長 268 bytes
コンパイル時間 388 ms
コンパイル使用メモリ 10,696 KB
実行使用メモリ 32,052 KB
最終ジャッジ日時 2023-09-28 02:42:00
合計ジャッジ時間 5,098 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,784 KB
testcase_01 AC 16 ms
7,864 KB
testcase_02 AC 246 ms
15,292 KB
testcase_03 AC 255 ms
15,308 KB
testcase_04 AC 440 ms
20,504 KB
testcase_05 AC 37 ms
9,048 KB
testcase_06 AC 369 ms
18,776 KB
testcase_07 AC 363 ms
22,124 KB
testcase_08 AC 22 ms
10,256 KB
testcase_09 AC 536 ms
25,732 KB
testcase_10 AC 572 ms
27,432 KB
testcase_11 AC 64 ms
11,736 KB
testcase_12 AC 740 ms
32,052 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,Q = map(int,input().split())
lr = [list(map(int,input().split()))for _ in range(Q)]
s = [0]*(N+1)

ans = 0
for l,r in lr:
    tmp1 = sum(s[l-1:r])
    for i in range(l-1,r):
        s[i]+=1
        s[i]%=2
    tmp2 = sum(s[l-1:r])
    ans+=(tmp2-tmp1)
    print(ans)
0