問題一覧 > ネタ問題

No.8132 Max Cover

レベル : / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 1024 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 11
作問者 : hirayuu_yc / テスター : highlighter
お気に入りにしたユーザー ProblemId : 13143 / 自分の提出
問題文最終更新日: 2026-04-01 21:29:13
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder April Fool Contest 2026 (順位表) の他の問題:

Note

There are no lies or hidden elements anywhere in this problem.

Problem Statement

A multiset of intervals is called a good set if, for every real number $k$ with $0\leq k\lt L$, the set contains an interval that contains $k$.

There is a multiset $s$ of intervals, and initially $s$ is empty. You are given $Q$ queries; process them in order. Each query is in one of the following $2$ formats.

  • 1 l r c: Add $c$ copies of the interval $[l:r)$ to $s$.
  • 2 l r c: Remove $c$ copies of the interval $[l:r)$ from $s$. It is guaranteed that at this point $s$ contains at least $c$ copies of the interval $[l:r)$.

Here, the interval $[l:r)$ refers to the interval that contains all real numbers $k$ with $l\leq k\lt r$ and no other real numbers.

Also, each time you process a query, find the answer to the following problem.

  • Find the maximum number of times the following operation can be performed.
    • $s$ has some of its elements chosen and removed. The multiset consisting of the chosen elements must be a good set.

Input

$Q$ $L$
$\text{query}_1$
$\text{query}_2$
$\vdots$
$\text{query}_Q$
  • $1\leq Q,L\leq 2\times 10^5$
  • $0\leq l\lt r\leq L$
  • $1\leq c\leq 10^9$
  • For a query of the form 2 l r c, $s$ contains at least $c$ copies of the interval $[l:r)$
  • All input values are integers

Output

Output $Q$ lines.

On line $i$, output the answer to the problem immediately after processing the $i$-th query.

Sample

Sample 1
Input
8 3
1 0 2 1
1 1 3 2
1 0 1 2
1 2 3 1
2 0 2 1
2 1 3 1
2 0 1 1
2 2 3 1
Output
0
1
2
3
2
1
1
1

Note

There really are no lies or hidden elements anywhere in this problem.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。