結果

問題 No.1673 Lamps on a line
ユーザー lam6er
提出日時 2025-03-20 20:16:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 117 ms / 2,000 ms
コード長 564 bytes
コンパイル時間 162 ms
コンパイル使用メモリ 82,568 KB
実行使用メモリ 105,608 KB
最終ジャッジ日時 2025-03-20 20:17:07
合計ジャッジ時間 1,923 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    import sys
    input = sys.stdin.read().split()
    idx = 0
    N = int(input[idx])
    idx += 1
    Q = int(input[idx])
    idx += 1

    lamps = [False] * (N + 2)  # 1-based indexing, up to N
    count = 0

    for _ in range(Q):
        L = int(input[idx])
        idx += 1
        R = int(input[idx])
        idx += 1
        for j in range(L, R + 1):
            if lamps[j]:
                count -= 1
            else:
                count += 1
            lamps[j] = not lamps[j]
        print(count)

if __name__ == '__main__':
    main()
0