結果

問題 No.1673 Lamps on a line
ユーザー stngstng
提出日時 2021-09-10 22:32:58
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 211 ms / 2,000 ms
コード長 384 bytes
コンパイル時間 1,757 ms
コンパイル使用メモリ 86,684 KB
実行使用メモリ 90,668 KB
最終ジャッジ日時 2023-09-02 18:59:43
合計ジャッジ時間 3,845 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,248 KB
testcase_01 AC 74 ms
71,136 KB
testcase_02 AC 171 ms
82,320 KB
testcase_03 AC 160 ms
82,392 KB
testcase_04 AC 198 ms
85,952 KB
testcase_05 AC 117 ms
78,016 KB
testcase_06 AC 186 ms
84,500 KB
testcase_07 AC 168 ms
85,196 KB
testcase_08 AC 91 ms
78,652 KB
testcase_09 AC 199 ms
85,644 KB
testcase_10 AC 211 ms
88,200 KB
testcase_11 AC 120 ms
80,088 KB
testcase_12 AC 209 ms
90,668 KB
権限があれば一括ダウンロードができます

ソースコード

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