随笔分类 - 贪心
摘要:题目链接 该题求的是中位数。故我们先将奶牛按分数进行升序排序。 由于一定是奇数。故该奶牛前面有n/2个,后面有n/2个。 故我们从n/2+1那个奶牛开始计算花费。不断把前面n/2个中花费最大的奶牛去除换成自己。(这就需要用到优先队列了) 之后再从后n/2+1个奶牛开始向前遍历。计算花费。 最后从后往
阅读全文
摘要:本题解思路和大部分代码来源于:https://www.luogu.com.cn/paste/irkatb8j E. Restoring the Permutation(贪心) 如果q的前后两个字符不一样。那么都a,b两个串都插入后面的那个字符。 如果前后两个字符一样,那么a插入可插入的最小的那个,b
阅读全文
摘要:POJ 2376 Cleaning Shifts Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 51535 Accepted: 12380 Description Farmer John is assigning some of
阅读全文
摘要:Description - 题目描述 给定若干位十进制数,你可以通过选择一个非空子集并以某种顺序构建一个数。剩余元素可以用相同规则构建第二个数。除非构造的数恰好为0,否则不能以0打头。举例来说,给定数字0,1,2,4,6与7,你可以写出10和2467。当然写法多样:210和764,204和176,等
阅读全文
摘要:Problem Description Mahmoud has n line segments, the i-th of them has length ai. Ehab challenged him to use exactly 3 line segments to form a non-dege
阅读全文
摘要:Problem Description Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were gi
阅读全文
摘要:Problem Description Bash has set out on a journey to become the greatest Pokemon master. To get his first Pokemon, he went to Professor Zulu's Lab. Si
阅读全文
摘要:Problem Description One spring day on his way to university Lesha found an array A. Lesha likes to split arrays into several parts. This time Lesha de
阅读全文
摘要:Problem Description Think of New York as a rectangular grid consisting of N vertical avenues numerated from 1 to N and M horizontal streets numerated
阅读全文
摘要:Problem Description There are n employees in Alternative Cake Manufacturing (ACM). They are now voting on some very important question and the leading
阅读全文
摘要:Problem Description Long time ago Alex created an interesting problem about parallelogram. The input data for this problem contained four integer poin
阅读全文
摘要:Problem Description Bachgold problem is very easy to formulate. Given a positive integer n represent it as a sum of maximum possible number of prime n
阅读全文
摘要:Problem Description 小明最近宅在家里无聊,于是他发明了一种有趣的游戏,游戏道具是N张叠在一起的卡片,每张卡片上都有一个数字,数字的范围是0~9,游戏规则如下: 首先取最上方的卡片放到桌子上,然后每次取最上方的卡片,放到桌子上已有卡片序列的最右边或者最左边。当N张卡片全部都放到桌子
阅读全文
摘要:Problem Description “今年暑假不AC?”“是的。”“那你干什么呢?”“看世界杯呀,笨蛋!”“@#$%^&*%...”确实如此,世界杯来了,球迷的节日也来了,估计很多ACMer也会抛开电脑,奔向电视了。作为球迷,一定想看尽量多的完整的比赛,当然,作为新时代的好青年,你一定还会看一些
阅读全文
摘要:Problem Description The famous ACM (Advanced Computer Maker) Company has rented a floor of a building whose shape is in the following figure. The floo
阅读全文

浙公网安备 33010602011771号