結果
| 問題 |
No.1673 Lamps on a line
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-05-06 18:48:23 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 199 ms / 2,000 ms |
| コード長 | 261 bytes |
| コンパイル時間 | 236 ms |
| コンパイル使用メモリ | 82,176 KB |
| 実行使用メモリ | 90,240 KB |
| 最終ジャッジ日時 | 2024-11-24 01:08:00 |
| 合計ジャッジ時間 | 3,505 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 11 |
ソースコード
N, Q = map(int, input().split())
LR = [list(map(int, input().split())) for _ in range(Q)]
dp = [0 for _ in range(N)]
cnt = 0
for l, r in LR:
l-=1
r-=1
for i in range(l, r+1):
cnt-=dp[i]
dp[i]=1-dp[i]
cnt+=dp[i]
print(cnt)