QOJ.ac

QOJ

حد الوقت: 1.0 s حد الذاكرة: 256 MB مجموع النقاط: 100 الصعوبة: [عرض] قابلة للهجوم ✓

#7102. Live Love

الإحصائيات

DreamGrid 正在玩音乐游戏《Live Love》。他刚刚完成了一首由 $n$ 个音符组成的歌曲,并得到了一个结果序列 $A_1, A_2, \dots, A_n$(其中 $A_i \in \{\text{PERFECT, NON-PERFECT}\}$)。这首歌的得分等于结果序列的“最大连击数”(max-combo),即序列中连续 PERFECT 的最大数量。

形式化地说,$\text{max-combo}(A) = \max \{k \mid k \text{ 是一个整数,且存在一个整数 } i \text{ } (1 \le i \le n - k + 1) \text{ 使得 } A_i = A_{i+1} = A_{i+2} = \dots = A_{i+k-1} = \text{PERFECT}\}$。为了完整起见,我们定义 $\max(\emptyset) = 0$。

由于 DreamGrid 记性不好,他在演奏结束后立即忘记了结果序列。他只知道序列长度 $n$ 以及序列中 PERFECT 的总数 $m$。任何他可能得到的得分 $s$ 都必须满足:存在一个长度为 $n$、包含恰好 $m$ 个 PERFECT 和 $(n - m)$ 个 NON-PERFECT 的序列 $A'$,使得 $\text{max-combo}(A') = s$。现在他需要你的帮助,找出所有可能得分中的最大值和最小值。

输入格式

输入包含多组测试数据。第一行包含一个整数 $T(1 \le T \le 100)$,表示测试数据的组数。对于每组测试数据:

仅一行,包含两个整数 $n$ 和 $m$ $(1 \le n \le 10^3, 0 \le m \le 10^3, m \le n)$,分别表示序列长度和 DreamGrid 得到的 PERFECT 数量。

输出格式

对于每组测试数据,输出一行,包含两个整数 $s_{max}$ 和 $s_{min}$,分别表示可能的最大得分和最小得分。

样例

输入 1

5
5 4
100 50
252 52
3 0
10 10

输出 1

4 2
50 1
52 1
0 0
10 10

说明

用 $P$ 表示 PERFECT,用 $N$ 表示 NON-PERFECT。

对于第一个样例,序列 $(P, P, P, P, N)$ 导致了最大得分,而序列 $(P, P, N, P, P)$ 导致了最小得分。

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.