303017: CF587A. Duff and Weight Lifting
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Duff and Weight Lifting
题意翻译
有$n$个数$w_1,w_2......w_{n-1},w_n$,若有$k$个$w$值满足存在一个数$x$使得$2^x$为这$k$个$2^w$的和,则这一组合是合法的,我们希望找到最小的组数$m$,使这$n$个$w$组成$m$个合法组合。 给出$n$和$w_i$,输出最小的$m$。题目描述
Recently, Duff has been practicing weight lifting. As a hard practice, Malek gave her a task. He gave her a sequence of weights. Weight of $ i $ -th of them is $ 2^{w_{i}} $ pounds. In each step, Duff can lift some of the remaining weights and throw them away. She does this until there's no more weight left. Malek asked her to minimize the number of steps. ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF587A/ae0bf97f46f744ec67cd3653eed80d2fdb7f3472.png)Duff is a competitive programming fan. That's why in each step, she can only lift and throw away a sequence of weights $ 2^{a_{1}},...,2^{a_{k}} $ if and only if there exists a non-negative integer $ x $ such that $ 2^{a_{1}}+2^{a_{2}}+...+2^{a_{k}}=2^{x} $ , i. e. the sum of those numbers is a power of two. Duff is a competitive programming fan, but not a programmer. That's why she asked for your help. Help her minimize the number of steps.输入输出格式
输入格式
The first line of input contains integer $ n $ ( $ 1<=n<=10^{6} $ ), the number of weights. The second line contains $ n $ integers $ w_{1},...,w_{n} $ separated by spaces ( $ 0<=w_{i}<=10^{6} $ for each $ 1<=i<=n $ ), the powers of two forming the weights values.
输出格式
Print the minimum number of steps in a single line.
输入输出样例
输入样例 #1
5
1 1 2 3 3
输出样例 #1
2
输入样例 #2
4
0 1 2 3
输出样例 #2
4