結果

問題 No.1673 Lamps on a line
ユーザー stngstng
提出日時 2021-09-10 22:32:58
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 196 ms / 2,000 ms
コード長 384 bytes
コンパイル時間 537 ms
コンパイル使用メモリ 82,360 KB
実行使用メモリ 88,960 KB
最終ジャッジ日時 2024-06-12 01:25:52
合計ジャッジ時間 3,101 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

n,q = map(int,input().split())
lr = [[int(i)-1 for i in input().split()] for j in range(q)]

rp = [0]*n
on = 0
off = n

for i in range(q):
    for j in range(lr[i][1]-lr[i][0]+1):
        if rp[lr[i][0]+j] == 0:
            rp[lr[i][0]+j] = 1
            off -= 1
            on += 1
        else:
            rp[lr[i][0]+j] = 0
            off += 1
            on -= 1
    print(on)
0