QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 512 MB Total points: 100 Hackable ✓

#17316. Update Problem

统计

整数 $n$ が与えられます。この整数に対して、以下の2種類の操作を行うことができます。

  • $n \leftarrow n+1$:$n$ を $1$ 増やす。
  • $n \leftarrow -n$:$n$ に $-1$ を掛ける。

今、第1の操作を $a$ 回、第2の操作を $b$ 回、任意の順序で行う必要があります。操作の過程における $|n|$ の最大値を $m$ とするとき、$m$ を可能な限り小さくし、その最小値を求めてください。

入力

本問は複数のテストケースを含みます。

入力の1行目には、2つの非負整数 $c, t$ が含まれており、それぞれテストケース番号とテストケースの数を示します。$c=0$ の場合、そのテストケースはサンプルであることを示します。

続いて各テストケースが順に入力されます。各テストケースは以下の通りです。

  • 1行に3つの整数 $n, a, b$ が含まれます。

出力

各テストケースについて:

  • $m$ の最小値を1行で出力してください。

入出力例

入出力例 1

0 5
0 5 1
0 6 2
0 114 514
250 5000 200
-13831 114514 1919810

入出力例 1

2
2
1
250
13831

注記

このサンプルには5つのテストケースが含まれています。

  • 1番目のテストケースでは、第1、第2、第1、第1、第1の順に操作を行うことで達成できます。
  • 2番目のテストケースでは、第1、第2、第1、第1、第2、第1の順に操作を行うことで達成できます。

制約

すべてのテストケースにおいて、以下が成り立ちます。

  • $1 \le t \le 10^5$
  • $0 \le |n|, a, b \le 10^9$
テストケース番号 $a\le$ $b\le$ 特殊性質
$1$ $10$ $10$ AC
$2$ $150$ $150$ CE
$3$ $2000$ $2000$ CE
$4$ $10^5$ $10^5$ CE
$5$ $2$ $10^9$ なし
$6$ $10^9$ $2$ B
$7$ $10^9$ $10^9$ B
$8$ $10^9$ $10^9$ C
$9$ $10^9$ $10^9$ D
$10$ $10^9$ $10^9$ なし
  • 特殊性質 A:$a + b \le 10$ を保証する。
  • 特殊性質 B:$n \ge 0$ を保証する。
  • 特殊性質 C:$n = 0$ を保証する。
  • 特殊性質 D:$n \le 0$ を保証する。
  • 特殊性質 E:$t \le 100$ を保証する。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.