CF1032E.The Unbearable Lightness of Weights

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You have a set of nn weights. You know that their masses are a1a_1 , a2a_2 , ..., ana_n grams, but you don't know which of them has which mass. You can't distinguish the weights.

However, your friend does know the mass of each weight. You can ask your friend to give you exactly kk weights with the total mass mm (both parameters kk and mm are chosen by you), and your friend will point to any valid subset of weights, if it is possible.

You are allowed to make this query only once. Find the maximum possible number of weights you can reveal after this query.

输入格式

The first line contains a single integer nn ( 1n1001 \le n \le 100 ) — the number of weights.

The second line contains nn integers a1,a2,,ana_1, a_2, \ldots, a_n ( 1ai1001 \le a_i \le 100 ) — the masses of the weights.

输出格式

Print the maximum number of weights you can learn the masses for after making a single query.

输入输出样例

  • 输入#1

    4
    1 4 2 2
    

    输出#1

    2
    
  • 输入#2

    6
    1 2 4 4 4 9
    

    输出#2

    2
    

说明/提示

In the first example we can ask for a subset of two weights with total mass being equal to 44 , and the only option is to get {2,2}\{2, 2\} .

Another way to obtain the same result is to ask for a subset of two weights with the total mass of 55 and get {1,4}\{1, 4\} . It is easy to see that the two remaining weights have mass of 22 grams each.

In the second example we can ask for a subset of two weights with total mass being 88 , and the only answer is {4,4}\{4, 4\} . We can prove it is not possible to learn masses for three weights in one query, but we won't put the proof here.

首页