問題一覧 > 通常問題

No.2142 Segment Zero

レベル : / AI推定難易度 : 1050 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 133
作問者 : milkcoffee / テスター : nok0 👑 qand
お気に入りにしたユーザー ProblemId : 8642 / 自分の提出
問題文最終更新日: 2022-11-25 22:32:42
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 contest 370 (順位表) の他の問題:

Problem Statement

There is an integer sequence $A$ of length $N$. Initially, $A_i=i$, that is, $A=(1,2,...,N)$. You can perform the following operation.

  • Choose integers $l,r \ (1 \leq l \leq r \leq N)$ and replace each of the values $A_l, A_{l+1}, \cdots , A_r$ with $0$.

Find the minimum number of operations required to make the sum of the elements of $A$ equal to $K$.

Input

$N$ $K$

  • $1 \leq N \leq 10^6$
  • $0 \leq K < \frac{N(N+1)}{2}$
  • All inputs are integers.

Output

Output, as an integer, the minimum number of operations required to make the sum of the elements of $A$ equal to $K$.

Sample

Sample 1
Input
5 7
Output
2

Initially, $A=(1,2,3,4,5)$.
First, performing the operation with $l=1,r=2$ gives $A=(0,0,3,4,5)$.
Next, performing the operation with $l=5,r=5$ gives $A=(0,0,3,4,0)$.
With $2$ operations, the sum of the elements of $A$ has been made equal to $7$.

Sample 2
Input
1000000 1000001
Output
1

It suffices to perform the operation with $l=2,r=999999$.

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