![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
贪心
mmk27
这个作者很懒,什么都没留下…
展开
-
HDU 4726 Kia's Calculation 贪心
Doctor Ghee is teaching Kia how to calculate the sum of two integers. But Kia is so careless and alway forget to carry a number when the sum of two digits exceeds 9. For example, when she calculates 4...原创 2018-11-21 23:37:55 · 256 阅读 · 0 评论 -
CodeForces - 1119E Pavel and Triangles 贪心
题目链接:点击查看题意 :有n种,2^0 2^1..2^n-1 种木棍,给出每种木棍的数目,求最多形成多少三角形题解:首先构成三角形要么等边,要么等腰,等腰的话另外一边只能取小的,如果小的有剩余,当然拿出2个来构成等腰更划算,如果没有那么就本身构成等边#include <bits/stdc++.h>using namespace std;typedef long lo...原创 2019-04-07 10:16:30 · 400 阅读 · 1 评论 -
ZOJ - 3715 Kindergarten Election 暴力+贪心
题目链接:点击查看题目:一共n个人投票,每个人最初有投票的对象和贿赂这个人需要的话费,求要想第一个人得票最多的最小话费题解:枚举第一个人的得票数,首先大于这个票数的都要投给一,先让话费小的给1,其他的都放到优先队列中,然后最后若票数还不够,那就在继续给第一个人#include<bits/stdc++.h>using namespace std;vector<in...原创 2019-03-28 22:04:19 · 141 阅读 · 3 评论 -
FZU - 2041 Checker 贪心+dp+二分
题目链接:https://vjudge.net/problem/FZU-2041题意:n的01串,可以移动1 m次,求最长的连续0的长度题解:每一段的0受左右最近的1影响,我们就枚举相邻的两个1,来求m次操作,使这两个1之间的0的连续长度最长, 预处理dp[i][j]表示i位置的1,移动到j位置的花费,然后我们枚举两个1的时候,前面的1枚举向左的位置,后面的1二分来求#...原创 2019-05-08 23:58:43 · 128 阅读 · 0 评论 -
2019 计蒜之道 复赛 “星云系统” 贪心
题目链接:https://nanti.jisuanke.com/t/39614题解:首先把每个字符的位置保存下来,然后很容易就想到二分去做,但是T了,所以我们就可以O(n)去做,记录下位置后,直接枚举每一个位置即可,这样就枚举一遍#include<bits/stdc++.h>using namespace std;typedef long long ll;const i...原创 2019-06-16 18:49:49 · 171 阅读 · 0 评论 -
2019 计蒜之道 复赛 撑起信息安全“保护伞” 贪心
题目链接:https://nanti.jisuanke.com/t/39615题解:两种都从后往前,l记录左括号的数量,r记录右括号数量,找前驱时,要满足第一个符合的s[i]==')' && r>=l && l>0,然后前面的直接输出,先把多余的右括号输出,剩下相等的左右括号一块输出,找后驱要找第一个符合s[i]=='(' && r-...原创 2019-06-16 18:54:19 · 160 阅读 · 0 评论 -
Contest1789 - 2019年第二阶段我要变强个人训练赛第十二场 问题 A: Limited Insertion 思维贪心
题目描述Snuke has an empty sequence a.He will perform N operations on this sequence.In the i-th operation, he chooses an integer j satisfying 1≤j≤i, and insert j at position j in a (the beginning is p...原创 2019-07-08 09:35:35 · 189 阅读 · 0 评论 -
HDU - 6203 树链剖分+LCA+树状数组+贪心
题目链接:https://cn.vjudge.net/problem/HDU-6203题意:n+1 的树,有p条路径无法通行,问最多少点被破坏题解:按照每条路径(s,e)的lca的深度从大到小排序,若该路径上的点存在被标记的,则跳过,否则就把lca这个点破坏掉,至于为什么先破坏深度大的,因为深度大的对深度小的能起到限制作用,反之不行。那么判断路径上有没有被破坏的点,我们就可以想到树链剖分了...原创 2019-07-09 19:18:18 · 173 阅读 · 0 评论 -
Contest1802 - 2019年第二阶段我要变强个人训练赛第十八场 问题 N: 扶桑号战列舰 线段树+贪心
题目链接:http://icpc.upc.edu.cn/problem.php?cid=1802&pid=13问题 N: 扶桑号战列舰时间限制:1 Sec内存限制:128 MBSpecial Judge提交:169解决:52[提交] [状态] [命题人:admin]题目描述众所周知,一战过后,在世界列强建造超无畏级战列舰的竞争之中,旧日本海军根据“个...原创 2019-07-30 18:48:47 · 254 阅读 · 1 评论 -
2019 HDU多校 HDU - 6586 String 贪心
题目链接:https://cn.vjudge.net/problem/HDU-6586题意:给出一个序列,找到长度为k的字典序最小的子序列,并且给出每个字符的数量的限制题解:这个和计蒜客复赛的题很像,链接:https://blog.csdn.net/mmk27_word/article/details/92417741,但是这个给出了每个字符数量的限制,那么我们就预处理记录下每个位置后面每...原创 2019-07-23 12:56:42 · 233 阅读 · 0 评论 -
2019ccpc网络赛 HDU - 6705 path 贪心跑第k小的路径长度
题目链接:https://vjudge.net/problem/HDU-6705题解:建立源点 汇点 跑A*,到最后也一直超内存也真是菜到家了,A*时间空间怎么也得n^2,这个题原来是个贪心。。。。官方题解:先把每条边以 形式放进堆,堆按路径权值从小到大排序,然后每次取出堆顶,用v的出边扩展 新的路径。但是一个点的出度可能会非常大(如菊花图),可以发现,将出边排序之后,每次只需要扩 展...原创 2019-08-24 13:03:07 · 278 阅读 · 0 评论 -
2019杭电多校 HDU-6695 贪心
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6695题解:分成两组,其中一组最大的x - 另一组最大的y 绝对值最小题解:按照x从小到大排序,枚举最大x,比x大的都放到另一组,每处理完y记录一下,然后从前面找到大于x和小于x的最符合的,判断一下是否可取,然后就是很多x相等的,找一个y最符合的#include <bits/stdc...原创 2019-08-21 17:30:24 · 228 阅读 · 1 评论 -
Contest1816 - 2019年我能变强组队训练赛第九场 G Lexical Sign Sequence 贪心+树状数组
问题 G: Lexical Sign Sequence时间限制:1 Sec内存限制:128 MB[提交] [状态] [命题人:admin]题目描述Andi likes numbers and sequences, especially, sign sequences. A sign sequence is a sequence whichconsists of -1 and...原创 2019-08-27 00:10:23 · 175 阅读 · 0 评论 -
问题 I: Monitoring Ski Paths 树链剖分+LCA+树状数组+贪心
问题 I: Monitoring Ski Paths时间限制:1 Sec内存限制:128 MB[提交] [状态] [命题人:admin]题目描述Fresh powder on a sunny day: it is a great time to ski! Hardcore skiers flock to a large mountain in the Rockies to e...原创 2019-08-29 20:47:24 · 228 阅读 · 0 评论 -
CodeForces - 545D Queue 贪心 排序
题目链接:点击查看Little girl Susie went shopping with her mom and she wondered how to improve service quality.There are n people in the queue. For each person we know time ti needed to serve him. A person...原创 2019-02-27 13:50:39 · 250 阅读 · 0 评论 -
Coffee and Coursework CodeForces - 1118D2 二分+贪心
The only difference between easy and hard versions is the constraints.Polycarp has to write a coursework. The coursework consists of mm pages.Polycarp also has nn cups of coffee. The coffee in the...原创 2019-02-24 22:33:06 · 449 阅读 · 0 评论 -
HDU - 4723 How Long Do You Have to Draw
There are two horizontal lines on the XoY plane. One is y 1 = a, the other is y 2 = b(a < b). On line y 1, there are N points from left to right, the x-coordinate of which are x = c 1, c 2, ... , c...原创 2018-11-22 18:06:10 · 130 阅读 · 0 评论 -
ZOJ - 3963 Heap Partition 贪心+线段树
A sequence S = {s1, s2, ..., sn} is called heapable if there exists a binary tree T with n nodes such that every node is labelled with exactly one element from the sequence S, and for every non-root n...原创 2018-11-26 20:23:26 · 124 阅读 · 0 评论 -
Gym - 100513G FacePalm Accounting 贪心
StatementsAn owner of a small company FacePalm has recently learned that the city authorities plan to offer to small businesses to participate in improving parks and garden squares. However, credibl...原创 2018-11-26 21:21:26 · 160 阅读 · 0 评论 -
Gym - 100513E Election of a Mayor 贪心
The Berland capital is preparing for mayoral election. There are two candidates for the position: the current mayor and his rival. The rival is a serious competitor, and it's not easy for current mayo...原创 2018-11-26 21:28:35 · 267 阅读 · 0 评论 -
Gym - 100513D Data Center 贪心
The startup "Booble" has shown explosive growth and now it needs a new data center with the capacity of m petabytes. Booble can buy servers, there are n servers available for purchase: they have equal...原创 2018-11-26 21:36:08 · 227 阅读 · 0 评论 -
Gym - 100513F Ilya Muromets 贪心
Силачом слыву недаром — семерых одним ударом!From the Russian cartoon on the German fairy tale.Ilya Muromets is a legendary bogatyr. Right now he is struggling against Zmej Gorynych, a dragon with...原创 2018-11-26 21:50:58 · 326 阅读 · 0 评论 -
CodeForces - 299C Weird Game 贪心
Yaroslav, Andrey and Roman can play cubes for hours and hours. But the game is for three, so when Roman doesn't show up, Yaroslav and Andrey play another game.Roman leaves a word for each of them. E...原创 2018-11-27 08:57:44 · 225 阅读 · 0 评论 -
HDU - 6188 Duizi and Shunzi 贪心
Nike likes playing cards and makes a problem of it.Now give you n integers, ai(1≤i≤n)We define two identical numbers (eg: 2,2) a Duizi,and three consecutive positive integers (eg: 2,3,4) a Shunzi....原创 2018-12-06 16:18:42 · 118 阅读 · 0 评论 -
Gym - 101911A Coffee Break set保存 map标记 模拟
Recently Monocarp got a job. His working day lasts exactly mm minutes. During work, Monocarp wants to drink coffee at certain moments: there are nn minutes a1,a2,…,ana1,a2,…,an, when he is able and wi...原创 2018-12-17 17:08:07 · 218 阅读 · 0 评论 -
HDU - 4221 Greedy? 贪心
iSea is going to be CRAZY! Recently, he was assigned a lot of works to do, so many that you can't imagine. Each task costs Ci time as least, and the worst news is, he must do this work no later than t...原创 2018-12-23 14:56:15 · 138 阅读 · 0 评论 -
CodeForces - 450C Jzzhu and Chocolate 数学 贪心
Jzzhu has a big rectangular chocolate bar that consists of n × m unit squares. He wants to cut this bar exactly k times. Each cut must meet the following requirements:each cut should be straight (ho...原创 2018-12-12 12:03:29 · 144 阅读 · 0 评论 -
Gym - 101911B Glider 贪心
A plane is flying at a constant height of hh meters above the ground surface. Let's consider that it is flying from the point (−109,h)(−109,h) to the point (109,h)(109,h) parallel with OxOx axis.A g...原创 2018-12-18 13:11:52 · 332 阅读 · 0 评论 -
POJ - 4044 Score Sequence 模拟+贪心
题目链接:点击查看题意:给出两个班级的成绩,先按降序排序,去重。然后求连续的最长公共子序列。输出时,先输出最长公共子序列,然后按个位数字递增的顺序输出,若各位数字一样就按成绩递增。题解:模拟写就可以了#include<iostream>#include<cstdio>#include<algorithm>using namespace std...原创 2018-12-23 22:15:57 · 121 阅读 · 0 评论 -
2018北京网络赛 HihoCoder - 1835 K-Dimensional Foil II 计算几何 贪心 二分
题目链接:https://vjudge.net/problem/HihoCoder-1835题解:首先我们应该能想到到达图形的距离最近那肯定是垂直过去,也就是坐标变为(x1 - k, x2 - k, x3 - k...),假设图形原点的坐标为(x10, x20, x30 ...),如果某个xi - k == xi0 了,那么我们就不在让他减小了,也就是说当前维已经达到了最优的情况,因此我们每次...原创 2019-09-02 23:54:01 · 171 阅读 · 0 评论