結果
| 問題 |
No.1673 Lamps on a line
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-09-11 02:44:04 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 158 ms / 2,000 ms |
| コード長 | 491 bytes |
| コンパイル時間 | 368 ms |
| コンパイル使用メモリ | 82,304 KB |
| 実行使用メモリ | 110,256 KB |
| 最終ジャッジ日時 | 2024-06-13 02:24:01 |
| 合計ジャッジ時間 | 3,421 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 11 |
ソースコード
from sys import stdin
from sys import stdout
def main(inp, inps, put):
N, Q = map(int, inp().split())
L, R = list(zip(*map(lambda x: list(map(int, x.split())), inps())))
result = [0]*Q
bits = [1]*(N+2)
now_sum = 0
for i, (l, r) in enumerate(zip(L, R)):
for j in range(l, r+1):
now_sum += bits[j]
bits[j] *= -1
result[i] = now_sum
put("\n".join(map(str, result)))
main(stdin.readline, stdin.readlines, stdout.write)