贪心算法
爱上键盘的小哥哥
这个作者很懒,什么都没留下…
展开
-
Protecting the Flowers (贪心)
Farmer John went to cut some wood and left N (2 ≤ N ≤ 100,000) cows eating the grass, as usual. When he returned, he found to his horror that the cluster of cows was in his garden eating his beautiful原创 2017-07-30 18:11:41 · 543 阅读 · 0 评论 -
Destruction of a Tree (贪心)
You are given a tree (a graph with n vertices and n - 1 edges in which it's possible to reach any vertex from any other vertex using only its edges).A vertex can be destroyed if this vertex has even d...原创 2018-05-15 18:08:03 · 194 阅读 · 0 评论 -
Students in Railway Carriage (贪心)
There are n consecutive seat places in a railway carriage. Each place is either empty or occupied by a passenger.The university team for the Olympiad consists of a student-programmers and b student-at...原创 2018-05-16 21:19:19 · 291 阅读 · 0 评论 -
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 Shunz...原创 2018-06-06 09:42:05 · 283 阅读 · 0 评论 -
1003D. Coins and Queries(思维+贪心)
Polycarp has n coins, the value of the i-th coin is ai. It is guaranteed that all the values are integer powers of 2 (i.e. ai=2d for some non-negative integer number d).Polycarp wants to know answers ...原创 2018-07-08 10:09:11 · 778 阅读 · 0 评论 -
Exam (贪心)
As this term is going to end, DRD needs to prepare for his final exams. DRD has n exams. They are all hard, but their difficulties are different. DRD will spend at least ri hours on the i-th course b...原创 2018-07-11 16:06:48 · 436 阅读 · 0 评论 -
Minimum Ternary String (贪心)
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or ...原创 2018-07-18 10:55:20 · 840 阅读 · 0 评论 -
HDU-6300 Triangle Partition(贪心)
Problem DescriptionChiaki 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 the 3n poin...原创 2018-07-24 14:13:04 · 345 阅读 · 0 评论 -
1000C. Covered Points Count(线段覆盖问题)
You are given n segments on a coordinate line; each endpoint of every segment has integer coordinates. Some segments can degenerate to points. Segments can intersect with each other, be nested in each...原创 2018-07-14 11:11:24 · 1124 阅读 · 0 评论 -
Detachment HDU - 5976(贪心+逆元+二分)
In a highly developed alien society, the habitats are almost infinite dimensional space.In the history of this planet,there is an old puzzle.You have a line segment with x units’ length representing...原创 2018-07-21 20:34:19 · 208 阅读 · 0 评论 -
B - Turn the Rectangles(贪心)
There are n rectangles in a row. You can either turn each rectangle by 90degrees or leave it as it is. If you turn a rectangle, its width will be height, and its height will be width. Notice that yo...原创 2018-07-21 21:11:01 · 248 阅读 · 0 评论 -
Integer Intervals POJ - 1716(贪心 or 差分约束)
An integer interval [a,b], a < b, is a set of all consecutive integers beginning with a and ending with b.Write a program that: finds the minimal number of elements in a set containing at least tw...原创 2018-07-22 10:32:07 · 191 阅读 · 0 评论 -
2018中国大学生程序设计竞赛 - 网络选拔赛 Buy and Resell(贪心)
Problem DescriptionThe 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 dollar...原创 2018-08-27 17:12:29 · 202 阅读 · 0 评论 -
Messages (贪心)
There are n incoming messages for Vasya. The i-th message is going to be received after ti minutes. Each message has a cost, which equals to A initially. After being received, the cost of a message de...原创 2018-05-14 19:25:32 · 253 阅读 · 0 评论 -
Minimize the error (贪心)
You are given two arrays A and B, each of size n. The error, E, between these two arrays is defined . You have to perform exactly k1 operations on array A and exactly k2 operations on array B. In one ...原创 2018-05-18 16:03:55 · 493 阅读 · 0 评论 -
company(思维 + 贪心)
Problem DescriptionThere are n kinds of goods in the company, with each of them has a inventory of and direct unit benefit . Now you find due to price changes, for any goods sold on day i, if its dir...原创 2018-05-03 19:47:44 · 2238 阅读 · 0 评论 -
最少拦截系统 (贪心算法)
某国为了防御敌国的导弹袭击,发展出一种导弹拦截系统.但是这种导弹拦截系统有一个缺陷:虽然它的第一发炮弹能够到达任意的高度,但是以后每一发炮弹都不能超过前一发的高度.某天,雷达捕捉到敌国的导弹来袭.由于该系统还在试用阶段,所以只有一套系统,因此有可能不能拦截所有的导弹.怎么办呢?多搞几套系统呗!你说说倒蛮容易,成本呢?成本是个大问题啊.所以俺就到这里来求救了,请帮助计算一下最少需要多少套拦截原创 2017-08-16 12:27:04 · 606 阅读 · 0 评论 -
Tian Ji -- The Horse Racing(贪心)
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. He likes to play horse racing with the king and others.""Bot原创 2017-09-26 17:37:41 · 634 阅读 · 0 评论 -
Problem B: Ants (弹性碰撞)
An army of ants walk on a horizontal pole of length l cm, each with a constant speed of 1 cm/s. When a walking ant reaches an end of the pole, it immediatelly falls off it. When two ants meet they tur原创 2017-09-11 15:48:42 · 437 阅读 · 0 评论 -
Mike and gcd problem
Mike has a sequence A = [a1, a2, ..., an] of length n. He considers the sequence B = [b1, b2, ..., bn] beautiful if the gcd of all its elements is bigger than 1, i.e. . Mike wants to change his原创 2017-09-22 11:28:07 · 270 阅读 · 0 评论 -
Cormen — The Best Friend Of a Man (贪心)
Recently a dog was bought for Polycarp. The dog's name is Cormen. Now Polycarp has a lot of troubles. For example, Cormen likes going for a walk.Empirically Polycarp learned that the dog needs at原创 2017-12-14 20:21:07 · 413 阅读 · 0 评论 -
Appleman and Card Game
Appleman has n cards. Each card has an uppercase letter written on it. Toastman must choosek cards from Appleman's cards. Then Appleman should give Toastman some coins depending on the chosen cards.原创 2018-01-27 10:15:02 · 206 阅读 · 0 评论 -
840C. Phone Numbers(贪心)
And where the are the phone numbers?You are given a string s consisting of lowercase English letters and an integer k. Find the lexicographically smallest string t of length k, such that its set of le...原创 2018-02-26 20:29:33 · 321 阅读 · 0 评论 -
922D. 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 t consisting of letters ...原创 2018-02-12 17:02:23 · 641 阅读 · 0 评论 -
916C. Jamie and Interesting Graph(构图+思维)
Jamie has recently found undirected weighted graphs with the following properties very interesting: The graph is connected and contains exactly n vertices and m edges. All edge weights are integers a...原创 2018-02-14 19:06:14 · 488 阅读 · 0 评论 -
934B. A Prosperous Lot
Apart from Nian, there is a daemon named Sui, which terrifies children and causes them to become sick. Parents give their children money wrapped in red packets and put them under the pillow, so that w...原创 2018-02-14 22:36:07 · 485 阅读 · 4 评论 -
Lazier Salesgirl ZOJ - 3607 (贪心)
Kochiya Sanae is a lazy girl who makes and sells bread. She is an expert at bread making and selling. She can sell the i-th customer a piece of bread for price pi. But she is so lazy that she will fa...原创 2018-04-23 10:47:29 · 182 阅读 · 0 评论 -
Watering System (贪心)
Arkady wants to water his only flower. Unfortunately, he has a very poor watering system that was designed for nn flowers and so it looks like a pipe with nn holes. Arkady can only use the water that ...原创 2018-05-10 15:36:25 · 303 阅读 · 0 评论 -
1008B. Turn the Rectangles(贪心)
There are n rectangles in a row. You can either turn each rectangle by 90degrees or leave it as it is. If you turn a rectangle, its width will be height, and its height will be width. Notice that yo...原创 2018-09-05 10:54:29 · 173 阅读 · 0 评论