QOJ.ac

QOJ

시간 제한: 1 s 메모리 제한: 256 MB 총점: 100

#16695. 糖果

통계

Kristian 是一名售卖糖果的店主。他的店里有 $N$ 包糖果,每包糖果中可能含有不同数量的糖果。当有顾客来店里并索要 $K$ 颗糖果时,Kristian 必须拿出若干包糖果,使得这些包装中的糖果总数恰好等于 $K$。如果他无法做到这一点(例如,有人索要 $4$ 颗糖果,但店里只有 $5$ 包糖果,且每包里都只有 $3$ 颗),顾客通常会感到沮丧并离开。

因此,Kristian 想知道,利用他目前拥有的这些糖果包,他能为下一位顾客提供多少种不同的糖果数量选择。他已经成功解决了这个问题,现在他想知道如何改进这个结果。他希望打开其中一个糖果包,并改变其中的糖果数量,使得他能提供给顾客的不同糖果数量选择的总数(即能凑出的不同正整数和的个数)尽可能多。

输入格式

第一行包含一个整数 $N$($2 \le N \le 100$)。

第二行包含一个由空格隔开的 $N$ 个整数组成的序列 $B_i$($1 \le B_i \le 7000$),表示每包糖果中的糖果数量。

输出格式

输出仅一行,包含两个由空格隔开的整数 $P$ 和 $Q$。这表示 Kristian 应该选择一包原本含有 $P$ 颗糖果的糖果包,并将其中的糖果数量改为 $Q$。

$P$ 必须等于原序列 $B_i$ 中的某一个值。如果存在多个最优解(即修改后能提供相同且最大数量的不同选择),输出 $P$ 最小的那个。在所有使 $P$ 最小的解中,选择 $Q$ 最小的那个。你可以认为 Kristian 总是可以通过修改单个糖果包来严格增加他能提供的不同糖果数量选择的总数。

样例

输入样例 1

4
1 3 4 4

输出样例 1

4 9

输入样例 2

5
3 3 3 3 3

输出样例 2

3 1

说明

对于第一个样例输入中所描述的糖果包(1, 3, 4, 4),Kristian 可以提供 9 种不同大小的糖果数量选择,分别为 1, 3, 4, 5, 7, 8, 9, 11 和 12。在将一包含有 4 颗糖果的糖果包改为 9 颗糖果后,他可以提供大小为 1, 3, 4, 5, 7, 8, 9, 10, 12, 13, 14, 16 和 17 的选择,总共包含 13 种不同的选择。

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
EditorialOpen Official EditorialQingyu- Download

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.