結果

問題 No.1673 Lamps on a line
ユーザー gr1msl3ygr1msl3y
提出日時 2021-09-10 21:24:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 211 ms / 2,000 ms
コード長 332 bytes
コンパイル時間 259 ms
コンパイル使用メモリ 87,044 KB
実行使用メモリ 102,048 KB
最終ジャッジ日時 2023-09-02 15:45:11
合計ジャッジ時間 3,290 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
71,080 KB
testcase_01 AC 70 ms
71,524 KB
testcase_02 AC 168 ms
87,968 KB
testcase_03 AC 166 ms
87,812 KB
testcase_04 AC 205 ms
91,824 KB
testcase_05 AC 120 ms
78,184 KB
testcase_06 AC 188 ms
92,388 KB
testcase_07 AC 178 ms
90,552 KB
testcase_08 AC 90 ms
78,576 KB
testcase_09 AC 203 ms
95,636 KB
testcase_10 AC 209 ms
97,148 KB
testcase_11 AC 117 ms
80,244 KB
testcase_12 AC 211 ms
102,048 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, Q = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(Q)]

state = [0]*(N)
ct = 0
ans = []
for l, r in A:
    for i in range(l-1, r):
        if state[i]:
            ct -= 1
            state[i] = 0
        else:
            ct += 1
            state[i] = 1
    ans.append(ct)

print(*ans, sep='\n')
0