QOJ.ac

QOJ

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

#17316. Update Problem

Statistics

Given an integer $n$, you can perform the following two operations:

  • $n \leftarrow n+1$, which increases $n$ by $1$.
  • $n \leftarrow -n$, which multiplies $n$ by $-1$.

You are required to perform the first operation $a$ times and the second operation $b$ times in any order. Let $m$ be the maximum value of $|n|$ during the process. You need to minimize $m$ and output this minimum value.

Input

This problem contains multiple test cases.

The first line of input contains two non-negative integers $c$ and $t$, representing the test case ID and the number of test cases, respectively. $c=0$ indicates that the test case is a sample.

Each test case is described by a single line containing three integers $n, a, b$.

Output

For each test case:

  • Output a single line containing an integer, representing the minimum value of $m$.

Examples

Input 1

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

Output 1

2
2
1
250
13831

Note 1

This sample contains $5$ test cases.

  • For the first test case, performing operations of type $1, 2, 1, 1, 1$ in order yields the result.
  • For the second test case, performing operations of type $1, 2, 1, 1, 2, 1$ in order yields the result.

Constraints

For all test cases:

  • $1 \le t \le 10^5$;
  • $0 \le |n|, a, b \le 10^9$.
Test Case ID $a\le$ $b\le$ Special Property
$1$ $10$ $10$ AC
$2$ $150$ $150$ CE
$3$ $2000$ $2000$ CE
$4$ $10^5$ $10^5$ CE
$5$ $2$ $10^9$ None
$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$ None
  • Special Property A: Guaranteed $a + b \le 10$.
  • Special Property B: Guaranteed $n \ge 0$.
  • Special Property C: Guaranteed $n = 0$.
  • Special Property D: Guaranteed $n \le 0$.
  • Special Property E: Guaranteed $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.