結果

問題 No.1673 Lamps on a line
ユーザー 👑 KazunKazun
提出日時 2021-09-10 21:23:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 126 ms / 2,000 ms
コード長 358 bytes
コンパイル時間 374 ms
コンパイル使用メモリ 87,284 KB
実行使用メモリ 84,604 KB
最終ジャッジ日時 2023-09-02 15:43:08
合計ジャッジ時間 2,856 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,392 KB
testcase_01 AC 76 ms
71,372 KB
testcase_02 AC 111 ms
79,824 KB
testcase_03 AC 103 ms
79,800 KB
testcase_04 AC 114 ms
81,396 KB
testcase_05 AC 92 ms
76,960 KB
testcase_06 AC 111 ms
81,216 KB
testcase_07 AC 115 ms
83,616 KB
testcase_08 AC 85 ms
78,944 KB
testcase_09 AC 121 ms
81,488 KB
testcase_10 AC 126 ms
83,044 KB
testcase_11 AC 89 ms
78,620 KB
testcase_12 AC 121 ms
84,604 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=sys.stdin.readline
write=sys.stdout.write
N,Q=map(int,input().split())
X=[0]*(N+1)
Ans=[]

S=0
for _ in range(Q):
    L,R=map(int,input().split())
    delta=0
    for k in range(L,R+1):
        if X[k]==0:
            delta+=1
        else:
            delta-=1
        X[k]^=1
    S+=delta
    Ans.append(S)

write("\n".join(map(str,Ans)))
0