题目:题解:贪心,根据右端点排序#include <bits/stdc++.h>using namespace std;struct node {    long long a,b;}p[100005];bool             
                
                    
                        
                                                            
                                                                        
                                                                                        原创
                                                                                    
                            2022-11-07 14:37:41
                            
                                54阅读
                            
                                                                             
                 
                
                                
                     
                                    
                             
         
            
            
            
            1 /* 2 先按右端点由小到大排序,相等的话左端点由大到小(否则会少算) 3 */ 4 #include <iostream> 5 #include <cstdlib> 6 #include <cstring> 7 using namespace std; 8 9 const int N = 10000;10 /**下面的不会用 11 typedef struct Node 12 {13 int a, b;14 bool operator < (const Node &node) const//此时使用sort排序 15 {16 return            
                
                    
                        
                                                            
                                                                        
                                                                                        转载
                                                                                    
                            2013-04-13 20:28:00
                            
                                31阅读
                            
                                                                                    
                                2评论
                            
                                                 
                 
                
                             
         
            
            
            
            #include#includeusing namesp            
                
                    
                        
                                                            
                                                                        
                                                                                        原创
                                                                                    
                            2022-08-30 10:13:05
                            
                                42阅读
                            
                                                                             
                 
                
                             
         
            
            
            
            请你在数轴上选择尽量少的点,使得每个区间内至少包含一个选出的点。输出一个整数,表            
                
                    
                        
                                                            
                                                                        
                                                                                        原创
                                                                                    
                            2023-04-22 07:23:25
                            
                                63阅读
                            
                                                                             
                 
                
                             
         
            
            
            
            昨天比赛的时候没有做出来,本来是想用贪心的,可是贪了好久都没有招, 今天在网上搜了解题报告~好像说这是一类区间选点问题: 有一个好的做法: (1)首先把题目中的时间全转化为分钟,那么区间就在0-1440中间 (2)对于n组人,有一个si 和一个ei,那么开个数组, cnt[si]+=d; cnt[e            
                
                    
                        
                                                            
                                                                        
                                                                                        转载
                                                                                    
                            2017-07-03 09:38:00
                            
                                53阅读
                            
                                                                                    
                                2评论
                            
                                                 
                 
                
                             
         
            
            
            
            题目传送门 一、题目解读 (1)每个线段上最少要选择一个点。 (2)如果一个点同时出现在两个线段上,就可以节约掉一个点。 给我们$N$个区间,问我们最少可以选择几个点。比如上图,就是可以选择两个点。 二、解题思路 贪心问题,区间问题无外乎就是排序, (1)按左端点排序 (2)按右端点排序 (3)双关            
                
                    
                        
                                                            
                                                                        
                                                                                        原创
                                                                                    
                            2021-10-29 09:48:55
                            
                                121阅读
                            
                                                                             
                 
                
                             
         
            
            
            
            一、贪心引入: 最少硬币 有1、2、5、10、20、50、100七种面值的硬币,要支付指定的金额,问怎么支付所用的硬币个数最少。 这是一个非常日常化的问题,马上我们会想到,尽可能先用大面值的硬币,就能使支付的硬币尽可能少。这就是“贪心选择”。 二、贪心——线段覆盖 题目 描述 学校的小礼堂每天都会有            
                
                    
                        
                                                            
                                                                        
                                                                                        转载
                                                                                    
                            2019-11-01 22:44:00
                            
                                568阅读
                            
                                                                                    
                                2评论
                            
                                                 
                 
                
                             
         
            
            
            
            uva 10148  AdvertisementThegging path at a local park. They have            
                
                    
                        
                                                            
                                                                        
                                                                                        原创
                                                                                    
                            2023-07-26 17:45:39
                            
                                41阅读
                            
                                                                             
                 
                
                             
         
            
            
            
            本文总结了C++中区间贪心算法的常见类型及解法:1)不相交区间选择(单组/多组),按右端点排序后贪心;2)区间选点问题,包            
                
         
            
            
            
            Describe:在数轴上标点,使得该点能够被区间覆盖,并要求对应区间最少覆盖Ki个点,求最少标多少个点保证满足要求,同一个位置不能重复;Input:第一行输入区间个数 n后面n行输入对应区间的起始坐标,终点坐标以及需覆盖点的个数Output:最少所需点的个数Example:Input:53 7 38 10 36 8 11 3 110 11 1Output:6Thinking: 首先依旧对所有区间            
                
                    
                        
                                                            
                                                                        
                                                                                        原创
                                                                                    
                            2022-01-04 17:08:02
                            
                                89阅读
                            
                                                                             
                 
                
                             
         
            
            
            
            非洲小孩时间限制:1000ms | 内存限制:65535KB难度:2描述家住非洲的小孩,都很黑。为什么呢?第一,他们地处热带,太阳辐射严重。第二,他们不经常洗澡。(常年缺水,怎么洗澡。)现在,在一个非洲部落里,他们只有一个地方洗澡,并且,洗澡时间很短,瞬间有木有!!(这也是没有的办法,缺水啊!!)每...            
                
                    
                        
                                                            
                                                                        
                                                                                        转载
                                                                                    
                            2015-07-27 15:33:00
                            
                                65阅读
                            
                                                                                    
                                2评论
                            
                                                 
                 
                
                             
         
            
            
            
            Radar InstallationTime Limit : 2000/1000ms (Java/Other)Memory Limit : 20000/10000K (Java/Other)Total Submission(s) : 22Accepted Submission(s) : 9Probl...            
                
                    
                        
                                                            
                                                                        
                                                                                        转载
                                                                                    
                            2015-07-31 16:48:00
                            
                                126阅读
                            
                                                                                    
                                2评论
                            
                                                 
                 
                
                             
         
            
            
            
             
Problem F"Advertisement"
 
 
The Department of Recreation has decided that it must be more profitable, and it wants to sell advertising space along a popular jogging path at a local park. They have             
                
                    
                        
                                                            
                                                                        
                                                                                        转载
                                                                                    
                            2013-08-20 22:00:00
                            
                                95阅读
                            
                                                                                    
                                2评论
                            
                                                 
                 
                
                             
         
            
            
            
            
#include 
#include 
using namespace std;
struct node
{
	in            
                
                    
                        
                                                            
                                                                        
                                                                                        原创
                                                                                    
                            2022-08-05 10:19:40
                            
                                91阅读
                            
                                                                             
                 
                
                             
         
            
            
            
            题意:给定一个数 n 个点,和一个d,要求在x轴上选出尽量少的点,使得对于给定的每个点,都有一个选出的点离它的欧几里德距离不超过d。 析:首先这是一个贪心的题目,并且是区间选点问题,什么是区间选点呢,就是说在数轴上有 n 个闭区间,取尽量少的点,使得每个区间都至少有一个点。 一看是不是和这个题很相似            
                
                    
                        
                                                            
                                                                        
                                                                                        转载
                                                                                    
                            2016-06-24 00:25:00
                            
                                44阅读
                            
                                                                             
                 
                
                             
         
            
            
            
            Assume the coasting is an infinite straight line. Land is in one side of coasting, sea in the other. Each small island is a point locating in the sea side. And any radar installation, locating on the coasting, can only coverddistance, so an island in the sea can be covered by a radius installation,            
                
                    
                        
                                                            
                                                                        
                                                                                        转载
                                                                                    
                            2013-08-24 20:53:00
                            
                                34阅读
                            
                                                                                    
                                2评论
                            
                                                 
                 
                
                             
         
            
            
            
               DescriptionAssume the coasting is an infinite straight line. Land is in one side of coasting, sea in the other. Each small island is a point locating in the sea side. And any radar i            
                
                    
                        
                                                            
                                                                        
                                                                                        原创
                                                                                    
                            2023-02-17 15:12:02
                            
                                49阅读
                            
                                                                             
                 
                
                                
                     
                                    
                             
         
            
            
            
            POJ1328 Radar Installation 【贪心·区间选点】            
                
                    
                        
                                                            
                                                                        
                                                                                        转载
                                                                                    
                            2017-04-24 20:02:00
                            
                                102阅读
                            
                                                                                    
                                2评论
                            
                                                 
                 
                
                             
         
            
            
            
            
Radar Installation
Time Limit: 1000MS
 
Memory Limit: 10000K
Total Submissions: 54798
 
Accepted: 12352
Description
Assume the coasting is an infinite straight line. Land is in one side of            
                
                    
                        
                                                            
                                                                        
                                                                                        转载
                                                                                    
                            2016-03-16 08:43:00
                            
                                234阅读
                            
                                                                                    
                                2评论