結果

問題 No.1673 Lamps on a line
ユーザー rlangevinrlangevin
提出日時 2023-02-06 22:15:13
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 319 ms / 2,000 ms
コード長 257 bytes
コンパイル時間 265 ms
コンパイル使用メモリ 86,720 KB
実行使用メモリ 80,972 KB
最終ジャッジ日時 2023-09-18 08:08:10
合計ジャッジ時間 3,898 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,104 KB
testcase_01 AC 73 ms
71,020 KB
testcase_02 AC 220 ms
77,016 KB
testcase_03 AC 222 ms
77,396 KB
testcase_04 AC 300 ms
77,288 KB
testcase_05 AC 113 ms
77,176 KB
testcase_06 AC 268 ms
77,104 KB
testcase_07 AC 234 ms
79,952 KB
testcase_08 AC 94 ms
78,668 KB
testcase_09 AC 299 ms
77,500 KB
testcase_10 AC 313 ms
78,864 KB
testcase_11 AC 114 ms
79,204 KB
testcase_12 AC 319 ms
80,972 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, Q  = map(int, input().split())
ans = 0
D = [0] * (N + 1)
for _ in range(Q):
    L, R = map(int, input().split())
    for i in range(L, R + 1):
        D[i] = 1 - D[i]
        if D[i]:
            ans += 1
        else:
            ans -= 1
    print(ans)
0