QOJ.ac

QOJ

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

#17316. Update Problem

Statistics

Update Problem

  • 时间限制:$1.0$ 秒
  • 空间限制:$512\text{ Mib}$

题目描述

给定一个整数 $n$,你可以对其进行下面的两种操作:

  • $n \leftarrow n+1$,即将 $n$ 增加 $1$。
  • $n \leftarrow -n$,即将 $n$ 乘上 $-1$。

现在,你需要按照任意顺序进行 $a$ 次第 $1$ 种操作和 $b$ 次第 $2$ 种操作。设操作过程中 $|n|$ 的最大值为 $m$,你需要使 $m$ 的值尽可能小,并求出该最小值。

输入格式

本题包含多组测试数据。

输入的第一行包含两个非负整数 $c,t$,分别表示测试点编号与测试数据组数。$c=0$ 表示该测试点为样例。

接下来依次输入每组测试数据,对于每组测试数据:

  • 共一行,包含三个整数 $n,a,b$。

输出格式

对于每组测试数据:

  • 输出一行,包含一个整数,表示 $m$ 的最小值。

样例 1 输入

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

样例 1 输出

2
2
1
250
13831

样例 1 解释

本组样例包含 $5$ 组测试数据。

  • 对于第 $1$ 组测试数据,依次进行第 $1,1,2,1,1,1$ 种操作即可。
  • 对于第 $2$ 组测试数据,依次进行第 $1,2,1,1,1,2,1,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.