hdu 6011 Lotus and Characters 贪心】的更多相关文章

http://acm.hdu.edu.cn/showproblem.php?pid=6011 先把数字从小到大排好,比如是-6.3.4这样, 然后处理出后缀和,当后缀和 <= 0的时候马上停止就好了. 证明: 假如现在是去到了第二个,也就是那个3,后缀和是7,那么我选不选-6呢? 如果选, 结果是: 1 * (-6) + 2 * 3 + 3 * 4 = 1 * (-6) + 3 + 4 + [1 * 3 + 2 * 4] 此时后缀和 > 0,对答案是有贡献的. #include <cst…
hdu 4825 Xor Sum(trie+贪心) 刚刚补了前天的CF的D题再做这题感觉轻松了许多.简直一个模子啊...跑树上异或x最大值.贪心地让某位的值与x对应位的值不同即可. #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #define CLR(a,b) memset((a),(b),sizeof(…
 Lotus and Characters  问题描述 Lotus有nn种字母,给出每种字母的价值以及每种字母的个数限制,她想构造一个任意长度的串. 定义串的价值为:第1位字母的价值*1+第2位字母的价值*2+第3位字母的价值*3…… 求Lotus能构造出的串的最大价值.(可以构造空串,因此答案肯定\geq 0≥0) 输入描述 第一行是数据组数T(0 \leq T \leq 1000)T(0≤T≤1000). 对于每组数据,第一行一个整数n(1 \leq n \leq 26)n(1≤n≤26),…
http://acm.hdu.edu.cn/showproblem.php?pid=6011 题意:共有n种字符,每种字符有一个val和一个cnt,代表这个字符的价值和数量.可以制造的总价值是:第一个字符的权值*1+第二个字符的权值*2+第三个字符的权值*3+…….问最大的总价值可以是多少. 思路:首先可以确定价值越大的是放在越后,因为后面的位权比较大.考虑到价值有负数,因为不确定负数是否要放上去,所以需要枚举这些负数. 首先输入的时候记录价值为负的个数negnum.将价值从小到大排序,然后枚举…
Keep On Movin 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5744 Description Professor Zhang has kinds of characters and the quantity of the i-th character is ai. Professor Zhang wants to use all the characters build several palindromic strings. He…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6011 题意: Lotus有nn种字母,给出每种字母的价值以及每种字母的个数限制,她想构造一个任意长度的串. 定义串的价值为:第1位字母的价值*1+第2位字母的价值*2+第3位字母的价值*3…… 求Lotus能构造出的串的最大价值.(可以构造空串,因此答案肯定\geq 0≥0) 分析: 做这个题目的时候,第一感觉回溯算了,不用想,肯定T了. #include <bits/stdc++.h> usin…
Balala Power! Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 1411    Accepted Submission(s): 239 Problem Description Talented Mr.Tang has n strings consisting of only lower case characters.…
Elegant Construction 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5813 Description Being an ACMer requires knowledge in many fields, because problems in this contest may use physics, biology, and even musicology as background. And now in this prob…
Windows 10 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5802 Description Long long ago, there was an old monk living on the top of a mountain. Recently, our old monk found the operating system of his computer was updating to windows 10 automatical…
Reorder the Books Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5500 Description dxy家收藏了一套书,这套书叫<SDOI故事集>,<SDOI故事集>有n(n≤19)n(n\leq 19)n(n≤19)本,每本书有一个编号,从111号到nnn号. dxy把这些书按编号从小到大,从上往下摞成一摞.dxy对这套书极其重视,不允许…