
贪心
empty_coder
这个作者很懒,什么都没留下…
展开
-
#1697 : 最小先序遍历
时间限制:10000ms 单点时限:1000ms 内存限制:256MB描述有一棵包含N个节点的二叉树,节点编号是1~N。 现在我们知道它的中序遍历结果A1, A2, … AN。只有中序遍历显然不能确定一棵二叉树的形态,可能有很多棵不同的二叉树符合给定的中序遍历。 那么你能从中找出先序遍历结果字典序最小的二叉树吗? 设先序遍历结果是P1, P2, … PN。字典序最小指首先P1应尽量小,其次原创 2018-03-03 15:19:30 · 487 阅读 · 0 评论 -
年会抢玩偶游戏
题目链接: 年会抢玩偶游戏题意: n个人站成一排来抢m个小玩偶,规定每个人抢到的礼物不能比左右两边的人多两个或以上,赢得游戏的人拥有最多的玩偶,问第k个位置的人在赢得游戏时拥有多少玩偶?分析:设第k位置的人拥有玩偶数为p,为了使其赢得游戏,我们自然地想到让(k-1)~1位置的人玩偶数依次减1,(k+1)~n的依次减1,令s = k(k-1)/2-(n-k+1)(n-k)/2,...原创 2018-04-09 16:05:10 · 1554 阅读 · 0 评论 -
Various Tree
题目链接:https://www.nowcoder.com/acm/contest/106/J题目描述:It‘s universally acknowledged that there’re innumerable trees in the campus of HUST.And there are many different types of trees in HUST, each of...原创 2018-04-30 22:59:36 · 197 阅读 · 0 评论 -
字典序最大的子序列
题目链接:https://www.nowcoder.com/acm/contest/84/A题目描述给定字符串s,s只包含小写字母,请求出字典序最大的子序列。 子序列:https://en.wikipedia.org/wiki/Subsequence 字典序:https://en.wikipedia.org/wiki/Lexicographical_order输入描述:一行一个字...原创 2018-04-30 23:47:25 · 3305 阅读 · 0 评论 -
计蒜客之贪心篇
1. 手机零件采购//费用最大为:2e9; 贪心#include <iostream>#include <algorithm>using namespace std;const int PRODUCER_MAX = 5005;struct part { int price, tot;};int part_tot, producer_tot;pa...原创 2018-07-09 21:09:58 · 370 阅读 · 0 评论