
贪心
文章平均质量分 91
LucienShui
因为孤独是人之常态,所以陪伴才显得格外可贵。
展开
-
Jungle Roads - HDU 1301 - 最小生成树
Jungle Roads - HDU 1301 - 最小生成树 这道题和Jungle Roads - POJ 1251 - Virtual Judge完全是一道题,直接把代码复制粘贴一遍就可以了。当时被作为Kruskal算法的例题。 代码传送门:Kruskal算法简明原创 2017-05-23 17:14:20 · 422 阅读 · 0 评论 -
Codeforces-985C - Liebig's Barrels - 贪心
题解链接https://lucien.ink/archives/234/题目链接http://codeforces.com/contest/985/problem/C题目You have m = n·k wooden staves. The i-th stave has length ai. You have to assemble n barrels consisti...原创 2018-05-22 08:54:37 · 1173 阅读 · 0 评论 -
Codeforces-985D - Sand Fortress - 二分 & 贪心
题解链接https://lucien.ink/archives/235/题目链接http://codeforces.com/contest/985/problem/D题目You are going to the beach with the idea to build the greatest sand castle ever in your head! The bea...原创 2018-05-22 09:12:36 · 1174 阅读 · 0 评论 -
Codeforces-1008B - Turn the Rectangles - 水题
题解链接https://www.lucien.ink/archives/306/题目链接http://codeforces.com/contest/1008/problem/B题目There are nnn rectangles in a row. You can either turn each rectangle by 909090 degrees or leave...原创 2018-07-14 01:02:10 · 562 阅读 · 0 评论 -
Codeforces-1008C - Reorder the Array - 水题
题解链接https://www.lucien.ink/archives/307/题目链接http://codeforces.com/contest/1008/problem/C题目You are given an array of integers. Vasya can permute (change order) its integers. He wants ...原创 2018-07-14 01:08:24 · 781 阅读 · 0 评论 -
HDU-6396 - Swordsman - 思维
题解链接https://www.lucien.ink/archives/316/题目链接http://acm.hdu.edu.cn/showproblem.php?pid=6396题目Lawson is a magic swordsman with k kinds of magic attributes v1,v2,v3,…,vk. Now Lawson is face...原创 2018-08-15 23:55:25 · 370 阅读 · 0 评论 -
Codeforces 1082B - Vova and Trophies
Codeforces 1082B - Vova and Trophies题解链接https://lucien.ink题目链接https://codeforces.com/contest/1082/problem/B题目 Vova has won nnn trophies in different competitions. Each trophy is either golden...原创 2018-12-01 01:28:33 · 259 阅读 · 0 评论 -
Codeforces 1082D - Maximum Diameter Graph - 贪心
Codeforces 1082D - Maximum Diameter Graph - 贪心题解链接https://lucien.ink题目链接https://codeforces.com/contest/1082/problem/D题目Graph constructive problems are back! This time the graph you are asked t...原创 2018-12-01 01:31:28 · 317 阅读 · 0 评论 -
Codeforces 1088E - Ehab and a component choosing problem - 贪心
Codeforces 1088E - Ehab and a component choosing problem题解链接https://lucien.ink题目链接https://codeforces.com/contest/1088/problem/E题目You’re given a tree consisting of nnn nodes. Every node uuu has...原创 2018-12-05 03:46:20 · 252 阅读 · 0 评论 -
Codeforces - 1098A - Sum in the tree
地址https://codeforces.com/contest/1098/problem/A原文地址https://www.lucien.ink/archives/400/题意给出一棵有点权的树,跟节点深度为 111 ,现在你只知道深度为奇数的点到数根的路经权值和,让你给所有点都分配一个非负的权值,满足所给和,且所有点权的和最小。如果不存在输出 −1-1−1 。题解对于权值和未知的...原创 2019-03-11 22:35:16 · 388 阅读 · 0 评论 -
Codeforces - 1098B - Nice table
地址https://codeforces.com/contest/1098/problem/A原文地址https://www.lucien.ink/archives/401/题意给你一个表格,上面只有四种字符 ATCGATCGATCG 。你可以把任意位置上的字符替换成这四种中的一种,问所有满足在替换之后对于每个 2⋅22 \cdot 22⋅2 的正方形四种字符全部都出现的表格中,且和原...原创 2019-03-11 22:44:31 · 379 阅读 · 0 评论 -
Codeforces - 1098C - Construct a tree
地址https://codeforces.com/contest/1098/problem/C原文地址https://www.lucien.ink/archives/402/题意能否构造出一棵 nnn 个节点的树,使得以每个点为根的子树的 sizesizesize 加起来等于 sss ,如果能,输出使得儿子最多的点的儿子数目最少的那种。题解不难看出,以每个点为根的子树的 sizesi...原创 2019-03-11 22:52:01 · 248 阅读 · 0 评论 -
Codeforces - 1139B - Chocolates
地址https://codeforces.com/contest/1139/problem/B原文地址https://www.lucien.ink/archives/407题意你有 nnn 堆物品,第 iii 堆物品有 aia_iai 个,如果你要从第 iii 堆物品中取走 xix_ixi 个,那么对于 1≤j<i1 \leq j < i1≤j<i ...原创 2019-03-25 01:28:34 · 284 阅读 · 0 评论 -
Codeforces - 1153C - Serval and Parenthesis Sequence
地址https://codeforces.com/contest/1153/problem/C原文地址https://www.lucien.ink/archives/415代码https://pasteme.cn/6250#include <bits/stdc++.h>const int maxn = int(1e6) + 7;int len, left, right;...原创 2019-04-15 00:06:56 · 270 阅读 · 0 评论 -
ARC-060E - Tak and Hotels - 贪心
题解链接https://lucien.ink/archives/229/题目链接https://arc060.contest.atcoder.jp/tasks/arc060_c题目Problem StatementN hotels are located on a straight line. The coordinate of the i-th hotel (...原创 2018-05-20 20:46:49 · 428 阅读 · 0 评论 -
HDU-2844 - Coins - 多重背包
链接: http://acm.hdu.edu.cn/showproblem.php?pid=2844题目:Problem DescriptionWhuacmers use coins.They have coins of value A1,A2,A3…An Silverland dollar. One day Hibix opened purse and found there were some原创 2017-09-19 17:14:40 · 400 阅读 · 0 评论 -
2017-05-12 华东师范大学网络邀请赛
今天写了华东师范大学的一场网络Contest,写了三个水题。原创 2017-05-13 02:08:01 · 423 阅读 · 0 评论 -
Kruskal算法简明
Kruskal算法简明 Kruskal(克鲁斯卡)算法和Prim算法般用于解决最小生成树问题,网上还有一个Prim+Heap的算法,空间复杂度比较高,但是效率很高。 Kruskal理解起来感觉会比prim好理解一些,和prim一样需要结合贪心思想,只是Kruskal需要结合并查集来使用。 算法的大致思想就是,先把所有的点等地位的铺开,然后先找到两个距离最近的点,将它们连起来,然后再找两个距离最原创 2017-05-15 14:33:32 · 630 阅读 · 0 评论 -
Prim算法简明
Prim算法简明 prim(普利姆)算法和Kruskal算法一般用于解决最小生成树问题,网上还有一个Prim+Heap的算法,空间复杂度比较高,但是效率很高。 这里来简要讲一下prim,大致意思就是先取一个点作为树根(随机哪个点都无所谓,因为最终每个点都会在最小生成树内,所以每个点都可以是树根),然后每次选一个距离当前已有生成树最近的一个点加入生成树形成一个新的生成树,如此一来当所有的点都加入生原创 2017-05-15 14:05:40 · 758 阅读 · 0 评论 -
小 Q 的棋盘 - UPCOJ 3779 - DFS + 贪心
链接 http://exam.upc.edu.cn/problem.php?id=3779题目:题目描述 小Q正在设计一种棋类游戏。在小Q设计的游戏中,棋子可以放在棋盘上的格点中。某些格点之间有连线,棋子只能在有连线的格点之间移动。整个棋盘上共有V个格点,编号为0,1,2…,V-1,它们是连通的,也就是说棋子从任意格点出发,总能到达所有的格点。小Q在设计棋盘时,还保证棋子从一个格点移动到另外任一原创 2017-08-01 16:47:10 · 467 阅读 · 0 评论 -
wtaxi - UPCOJ 3641 - 贪心DP 背包
链接: http://exam.upc.edu.cn/problem.php?id=3641题目:题目描述话说小 x 有一次去参加比赛,虽然学校离比赛地点不太远,但小 x 还是想坐出租车去。大学城的出租车总是比较另类,有“拼车”一说,也就是说,你一个人坐车去,还是一堆人一起,总共需要支付的钱是一样的(每辆出租上除司机外最多坐下 4 个人)。刚好那天同校的一群 Oier 在校门口扎堆了,大家果断决定原创 2017-08-01 17:00:06 · 294 阅读 · 0 评论 -
Codeforces-854C - Planning - 贪心
链接: http://codeforces.com/contest/854/problem/C题目:Helen works in Metropolis airport. She is responsible for creating a departure schedule. There are n flights that must depart today, the i-th of them原创 2017-09-07 01:20:39 · 1630 阅读 · 0 评论 -
HDU-1171 - Big Event in HDU - 01背包
链接: http://acm.hdu.edu.cn/showproblem.php?pid=1171题目:Problem DescriptionNowadays, we all know that Computer College is the biggest department in HDU. But, maybe you don’t know that Computer College ha原创 2017-09-07 01:36:27 · 328 阅读 · 0 评论 -
HDU-1864 - 最大报销额 - 01背包
链接: http://acm.hdu.edu.cn/showproblem.php?pid=1864题目:Problem Description现有一笔经费可以报销一定额度的发票。允许报销的发票类型包括买图书(A类)、文具(B类)、差旅(C类),要求每张发票的总额不得超过1000元,每张发票上,单项物品的价值不得超过600元。现请你编写程序,在给出的一堆发票中找出可以报销的、不超过给定额度的最大报原创 2017-09-07 01:38:43 · 352 阅读 · 0 评论 -
HDU-2018 - 母牛的故事 - 思维
链接: http://acm.hdu.edu.cn/showproblem.php?pid=2018题目:Problem Description有一头母牛,它每年年初生一头小母牛。每头小母牛从第四个年头开始,每年年初也生一头小母牛。请编程实现在第n年的时候,共有多少头母牛?Input输入数据由多个测试实例组成,每个测试实例占一行,包括一个整数n(0Output对于每个测试实例,输出在第n年的时候母原创 2017-09-07 01:41:24 · 383 阅读 · 0 评论 -
UPCOJ 4201 - Teacher’s Day - 二分贪心
链接: http://exam.upc.edu.cn/problem.php?id=4201题目:题目描述Teacher’s Day is coming, a group of n students decided to buy gifts. The store offered them M gifts. The price is different for different gifts, b原创 2017-08-31 00:06:41 · 356 阅读 · 0 评论 -
HDU-2546 - 饭卡 - 01背包
链接: http://acm.hdu.edu.cn/showproblem.php?pid=2546题目:Problem Description电子科大本部食堂的饭卡有一种很诡异的设计,即在购买之前判断余额。如果购买一个商品之前,卡上的剩余金额大于或等于5元,就一定可以购买成功(即使购买后卡上余额为负),否则无法购买(即使金额足够)。所以大家都希望尽量使卡上的余额最少。 某天,食堂中有n种菜出售原创 2017-09-19 17:02:45 · 430 阅读 · 0 评论 -
HDU-2602 - Bone Collector - 01背包
链接: http://acm.hdu.edu.cn/showproblem.php?pid=2602题目:Problem DescriptionMany years ago , in Teddy’s hometown there was a man who was called “Bone Collector”. This man like to collect varies of bones ,原创 2017-09-19 17:06:28 · 360 阅读 · 0 评论 -
第十届山东省赛 - H - Tokens on the Segments
题目链接http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=6022题意一维坐标轴上有 nnn 条线段,你可以在每个线段的整点上放任意多个标记,但是任意两个标记不能重合,问最多有多少条线段可以拥有标记。题解思路最原始的想法是二分图,但看了眼范围放弃了,考虑贪心。简单的贪心想法就是按照左右端点的升序进行二级排序,然后贪心地...原创 2019-05-14 13:19:01 · 326 阅读 · 0 评论