![](https://img-blog.csdnimg.cn/20201014180756913.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
【贪心算法】
riba2534
没有谁生来就是神牛,而千里之行,始于足下!
展开
-
NEU1511 Caoshen like math(使序列有序的最小交换次数)
题目描述 Worfzyq likes Permutation problems.Caoshen and Mengjuju are expert at these problems . They have n cards,and all of the numbers vi on these cards are different . Because Caoshen doesn’t原创 2017-12-18 20:03:13 · 2006 阅读 · 0 评论 -
HDU6034 Balala Power!(贪心,坑!!!)(2017 HDU多校联赛第一场)
题目:Balala Power!Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 2894 Accepted Submission(s): 637Problem Description原创 2017-07-26 12:22:12 · 645 阅读 · 0 评论 -
HDU1789 Doing Homework again(贪心)
题目:Doing Homework againTime Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 14180 Accepted Submission(s): 8227Problem Descriptio原创 2017-07-09 15:52:49 · 395 阅读 · 0 评论 -
POJ2376 Cleaning Shifts(贪心)
题目:Cleaning ShiftsTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 22287 Accepted: 5563DescriptionFarmer John is assigning some of his N (1原创 2017-07-09 15:11:48 · 382 阅读 · 0 评论 -
POJ1328 Radar Installation(贪心)
题目:Radar InstallationTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 88203 Accepted: 19777DescriptionAssume the coasting is an infinite st原创 2017-07-09 13:11:12 · 311 阅读 · 0 评论 -
POJ1323 Game Prediction(贪心)
题目:Game PredictionTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 10972 Accepted: 5284DescriptionSuppose there are M people, including you原创 2017-07-09 10:49:03 · 364 阅读 · 0 评论 -
POJ2393 Yogurt factory(贪心)
题目:Yogurt factoryTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 10782 Accepted: 5469DescriptionThe cows have purchased a yogurt factory t原创 2017-07-08 17:19:17 · 769 阅读 · 0 评论 -
POJ2325 Persistent Numbers(大数+贪心)
题目:Persistent NumbersTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 3698 Accepted: 1740DescriptionThe multiplicative persistence of a num原创 2017-07-08 00:05:22 · 1006 阅读 · 0 评论 -
HDU2124 Repair the Wall(贪心)
题目:Repair the WallTime Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4574 Accepted Submission(s): 2262Problem DescriptionL原创 2017-07-07 14:48:29 · 300 阅读 · 0 评论 -
“科林明伦杯”哈尔滨理工大学第七届程序设计团队赛 G.Sorting(贪心,思路)
Description You have an integer sequence a1 … an (integers are distinct) and you need to sort it by ascending order. However, you can only swap two integers at a time and the cost is (ai + aj)原创 2017-12-18 23:44:06 · 424 阅读 · 1 评论 -
51Nod - 1125 交换机器的最小代价(贪心,思路)
描述 有N台机器重量各不相等,现在要求把这些机器按照重量排序,重量从左到右依次递增。移动机器只能做交换操作,但交换机器要花费一定的费用,费用的大小就是交换机器重量的和。例如:3 2 1,交换1 3后为递增排序,总的交换代价为4。给出N台机器的重量,求将所有机器变为有序的最小代价。(机器的重量均为正整数)Input 第1行:1个数N,表示机器及房间的数量。(2 <= N <= 5000原创 2017-12-18 23:22:10 · 651 阅读 · 0 评论 -
ZOJ2319 Beautiful People(贪心,最长递增子序列nlogn,LIS)
题目: Beautiful People Time Limit: 5 Seconds Memory Limit: 32768 KB Special Judge The most prestigious sports club in one city has exactly N members. Each of its members is strong and b原创 2017-04-19 16:31:58 · 630 阅读 · 0 评论 -
HDU6348 Buy and Resell(2018CCPC网络赛,优先队列,贪心)
Problem Description The Power Cube is used as a stash of Exotic Power. There are n cities numbered 1,2,…,n where allowed to trade it. The trading price of the Power Cube in the i-th city is ai dol...原创 2018-08-31 22:19:06 · 278 阅读 · 0 评论 -
CodeForces 867E Buy Low Sell High(优先队列,贪心)
描述 You can perfectly predict the price of a certain stock for the next N days. You would like to profit on this knowledge, but only want to transact one share of stock per day. That is, each day y...原创 2018-08-31 21:57:31 · 308 阅读 · 0 评论 -
HDU6409 没有兄弟的舞会(2018百度之星复赛,贪心)
Problem Description 度度熊、光羽、带劲三个人是好朋友。 度度熊有一棵n个点的有根树,其中1号点为树根。除根节点之外,每个点都有父节点,记i号点的父节点为fa[i]。 度度熊称点i和点j是兄弟(其中i≠j)当且仅当fa[i]=fa[j]。 第i个点的权值为Ai。现要求选出一个点集,该点集合法当且仅当点集中至多只有一对兄弟。 度度熊想知道,在所有可行...原创 2018-08-20 10:38:56 · 527 阅读 · 0 评论 -
HDU6299 Balanced Sequence(2018HDU多校联赛第一场,思路,贪心)
Problem Description Chiaki has n strings s1,s2,…,sn consisting of ‘(’ and ‘)’. A string of this type is said to be balanced: if it is the empty string if A and B are balanced, AB is b...原创 2018-07-24 13:14:24 · 332 阅读 · 0 评论 -
HDU6301 Distinct Values(2018HDU多校联赛第一场,思路,贪心,set)
Problem Description Chiaki has an array of n positive integers. You are told some facts about the array: for every two elements ai and aj in the subarray al..r (l≤iInput There are mult...原创 2018-07-24 02:00:09 · 559 阅读 · 0 评论 -
HDU6300 Triangle Partition(2018HDU多校联赛第一场,贪心)
Problem Description Chiaki has 3n points p1,p2,…,p3n. It is guaranteed that no three points are collinear. Chiaki would like to construct n disjoint triangles where each vertex comes from th...原创 2018-07-24 00:46:22 · 510 阅读 · 0 评论 -
CodeForces - 551C GukiZ hates Boxes(二分+贪心)
描述 Professor GukiZ is concerned about making his way to school, because massive piles of boxes are blocking his way. In total there are n piles of boxes, arranged in a line, from left to ...原创 2018-04-20 15:25:09 · 360 阅读 · 0 评论 -
HDU6000 Wash(优先队列+贪心)
Problem Description Mr.Panda is about to engage in his favourite activity doing laundry! He’s brought L indistinguishable loads of laundry to his local laundromat, which has N washing machin...原创 2018-04-04 13:52:27 · 563 阅读 · 0 评论 -
Codeforces Round #461 (Div. 2) D. Robot Vacuum Cleaner(贪心,思路)
描述 Pushok the dog has been chasing Imp for a few hours already. Fortunately, Imp knows that Pushok is afraid of a robot vacuum cleaner. While moving, the robot generates a string ...原创 2018-02-08 14:57:12 · 299 阅读 · 0 评论 -
Codeforces Round #457 (Div. 2) B. Jamie and Binary Sequence(二进制,思路,贪心)
描述 Jamie is preparing a Codeforces round. He has got an idea for a problem, but does not know how to solve it. Help him write a solution to the following problem: Find k integers such t原创 2018-01-20 15:23:28 · 790 阅读 · 2 评论 -
HDU1800 Flying to the Mars(贪心)
题目:Flying to the MarsTime Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 20173 Accepted Submission(s): 6479Problem Description原创 2017-07-07 11:44:05 · 291 阅读 · 0 评论 -
HDU1052 Tian Ji -- The Horse Racing(贪心)
题目:Tian Ji -- The Horse RacingTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 30306 Accepted Submission(s): 9150Problem Des原创 2017-07-07 11:26:23 · 404 阅读 · 0 评论 -
HDU1051 Wooden Sticks(贪心)
题目:Wooden SticksTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 21900 Accepted Submission(s): 8783Problem DescriptionTh原创 2017-07-07 09:45:54 · 436 阅读 · 0 评论 -
NYOJ236 心急的C小加
题目:心急的C小加时间限制:1000 ms | 内存限制:65535 KB难度:4描述C小加有一些木棒,它们的长度和质量都已经知道,需要一个机器处理这些木棒,机器开启的时候需要耗费一个单位的时间,如果第i+1个木棒的重量和长度都大于等于第i个处理的木棒,那么将不会耗费时间,否则需要消耗一个单位的时间。因为急着去约会,C小加想在最短的时间内原创 2016-11-15 19:24:05 · 442 阅读 · 0 评论 -
NYOJ364 田忌赛马
题目:田忌赛马时间限制:3000 ms | 内存限制:65535 KB难度:3描述Here is a famous story in Chinese history."That was about 2300 years ago. General Tian Ji was a high official in the country Qi.原创 2016-11-16 10:27:29 · 377 阅读 · 0 评论 -
HDU2570 迷瘴
题目:迷瘴Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 7024 Accepted Submission(s): 2354Problem Description通过悬崖的yifenfei,原创 2016-11-16 17:28:41 · 336 阅读 · 0 评论 -
HDU2111 Saving HDU
题目: Saving HDU Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 9971 Accepted Submission(s): 4668 Problem Description话说上回讲到海...原创 2016-11-16 17:53:25 · 420 阅读 · 2 评论 -
NYOJ1036 非洲小孩(又一道贪心水题,区间选点问题)
题目:非洲小孩时间限制:1000 ms | 内存限制:65535 KB难度:2描述家住非洲的小孩,都很黑。为什么呢?第一,他们地处热带,太阳辐射严重。第二,他们不经常洗澡。(常年缺水,怎么洗澡。)现在,在一个非洲部落里,他们只有一个地方洗澡,并且,洗澡时间很短,瞬间有木有!!(这也是没有的办法,缺水啊!!)每个小孩有一个时间段能够原创 2016-11-08 21:28:22 · 576 阅读 · 0 评论 -
NSWOJ2180 - 最大的数
题目: 2180 - 最大的数时间限制:1秒 内存限制:128兆6 次提交 3 次通过提交题目描述小明和小红在打赌说自己数学学的好,于是小花就给他们出题了,考考他们谁NB,题目是这样的给你N个数在这n个数之间添加N-1个*或+,使结果最大,但不可以打乱原顺序,请得出这个结果如1 3 5结果是(1+3)*5=20;最大可以添加若干个括号,但一定要保证配对...原创 2016-11-10 21:14:31 · 1496 阅读 · 0 评论 -
NYOJ448 寻找最大数
题目:寻找最大数时间限制:1000 ms | 内存限制:65535 KB难度:2描述请在整数 n 中删除m个数字, 使得余下的数字按原次序组成的新数最大,比如当n=92081346718538,m=10时,则新的最大数是9888 输入第一行输入一个正整数T,表示有T组测试数据每组测试数据占一行,每行有两个数原创 2016-11-09 21:55:41 · 373 阅读 · 0 评论 -
NYOJ71 独木舟上的旅行
题目:代码:#include #include #include using namespace std;int main(){ int t; scanf("%d",&t); while(t--) { int weight,numr; scanf("%d %d",&weight,&numr);原创 2016-11-09 17:42:42 · 329 阅读 · 0 评论 -
NYOJ106 背包问题
题目:背包问题时间限制:3000 ms | 内存限制:65535 KB难度:3描述现在有很多物品(它们是可以分割的),我们知道它们每个物品的单位重量的价值v和重量w(1<=v,w<=10);如果给你一个背包它能容纳的重量为m(10<=m<=20),你所要做的就是把物品装到背包里,使背包里的物品的价值总和最大。输入第一行输入一个正整数n原创 2016-11-09 10:56:07 · 616 阅读 · 0 评论 -
nyoj915 +-字符串(贪心)
+-字符串时间限制:1000 ms | 内存限制:65535 KB难度:1描述Shiva得到了两个只有加号和减号的字符串,字串长度相同。Shiva一次可以把一个加号和它相邻的减号交换。他想知道最少需要多少次操作才能把第一个字符串变换成第二个字符串。你现在要去帮助他完成那个这个问题。输入多组测试数据每组数据有两行,每行包含一个由”+”和”-“最原创 2016-11-07 21:50:31 · 575 阅读 · 0 评论 -
NYOJ891 选点
题目:找点时间限制:2000 ms | 内存限制:65535 KB难度:2描述上数学课时,老师给了LYH一些闭区间,让他取尽量少的点,使得每个闭区间内至少有一个点。但是这几天LYH太忙了,你们帮帮他吗?输入多组测试数据。每组数据先输入一个N,表示有N个闭区间(N≤100)。接下来N行,每行输入两个数a,b(0≤a≤b≤原创 2016-11-11 21:19:23 · 364 阅读 · 0 评论 -
POJ3617 Best Cow Line(字典序最小问题)
题目:Best Cow LineTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 20680 Accepted: 5673DescriptionFJ is about to take his N (1 ≤ N ≤ 2,000) c原创 2016-11-17 17:35:28 · 438 阅读 · 0 评论 -
POJ3069 Saruman's Army
题目:Saruman's ArmyTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 8359 Accepted: 4257DescriptionSaruman the White must lead his army alon原创 2016-11-17 20:48:29 · 291 阅读 · 0 评论 -
HDU1050 Moving Tables(贪心)
题目:Moving TablesTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 35999 Accepted Submission(s): 11852Problem DescriptionT原创 2017-07-07 08:51:29 · 480 阅读 · 0 评论 -
2017 计蒜之道 初赛 第五场 A. UCloud 机房的网络搭建(贪心)
题目: 14.7% 1000ms 131072KUCloud 刚刚建立一个新机房,近日正在进行网络搭建。机房内有 nn 台服务器和 mm 个分线器,整个机房只有一个网线出口。分线器的作用是将一根网线转换成多根网线。蒜头君也知道每个分线器输出的最大网线根数(不一定要将分线器输出的每根线都用上),问你至少需要使用多少个分线器才能使得每台服务器都有网线可用。输入格式原创 2017-06-04 19:21:27 · 666 阅读 · 0 评论