![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
贪心
文章平均质量分 75
ComBoat
俺好菜呀o(╥﹏╥)o
展开
-
HDU 1528 Card Game Cheater(贪心)
Problem DescriptionAdam and Eve play a card game using a regular deck of 52 cards. The rules are simple. The players sit on opposite sides of a table, facing each other. Each player gets k cards from the deck and, after looking at them, places the cards f原创 2021-02-23 17:54:57 · 114 阅读 · 0 评论 -
POJ 1024 Gone Fishing(贪心)
DescriptionJohn is going on a fishing trip. He has h hours available (1 <= h <= 16), and there are n lakes in the area (2 <= n <= 25) all reachable along a single, one-way road. John starts at lake 1, but he can finish at any lake he wants. He原创 2021-02-21 23:03:27 · 158 阅读 · 0 评论 -
POJ 1238 Radar Installation(贪心)
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 installation, locating on the coasting, can only cover d distance, so an i原创 2021-02-21 21:22:30 · 91 阅读 · 0 评论 -
POJ 3190 Stall Reservations(贪心 优先队列)
DescriptionOh those picky N (1 <= N <= 50,000) cows! They are so picky that each one will only be milked over some precise time interval A…B (1 <= A <= B <= 1,000,000), which includes both times A and B. Obviously, FJ must create a reservat原创 2021-02-21 19:28:22 · 140 阅读 · 0 评论 -
OpenJudge 16067 电影节(贪心)
描述大学生电影节在北大举办! 这天,在北大各地放了多部电影,给定每部电影的放映时间区间,区间重叠的电影不可能同时看(端点可以重合),问李雷最多可以看多少部电影。输入多组数据。每组数据开头是n(n<=100),表示共n场电影。接下来n行,每行两个整数(0到1000之间),表示一场电影的放映区间n=0则数据结束输出对每组数据输出最多能看几部电影样例输入83 40 73 815 1915 2010 158 186 120样例输出3思路将电影的结束时间按照从小到大排原创 2021-02-21 16:49:45 · 268 阅读 · 0 评论 -
Codeforces 602B Approximating a Constant Range
descriptionWhen Xellos was doing a practice course in university, he once had to measure the intensity of an effect that slowly approached equilibrium. A good way to determine the equilibrium intensity would be choosing a sufficiently large number of cons原创 2021-02-21 11:06:57 · 134 阅读 · 0 评论 -
CordForce 604B More Cowbell(贪心 二分)
descriptionKevin Sun wants to move his precious collection of n cowbells from Naperthrill to Exeter, where there is actually grass instead of corn. Before moving, he must pack his cowbells into k boxes of a fixed size. In order to keep his collection safe原创 2021-02-20 11:13:28 · 164 阅读 · 0 评论 -
CodeForce 191B Demonstration(贪心)
descriptionIn the capital city of Berland, Bertown, demonstrations are against the recent election of the King of Berland. Berland opposition, led by Mr. Ovalny, believes that the elections were not fair enough and wants to organize a demonstration at one原创 2021-02-18 21:44:10 · 142 阅读 · 0 评论 -
HDU 1050 Moving Tables(贪心 差分)
Problem DescriptionThe famous ACM (Advanced Computer Maker) Company has rented a floor of a building whose shape is in the following figure.The floor has 200 rooms each on the north side and south side along the corridor. Recently the Company made a pla原创 2021-02-17 20:17:18 · 170 阅读 · 0 评论 -
luogu P1020 导弹拦截
题目描述某国为了防御敌国的导弹袭击,发展出一种导弹拦截系统。但是这种导弹拦截系统有一个缺陷:虽然它的第一发炮弹能够到达任意的高度,但是以后每一发炮弹都不能高于前一发的高度。某天,雷达捕捉到敌国的导弹来袭。由于该系统还在试用阶段,所以只有一套系统,因此有可能不能拦截所有的导弹。输入导弹依次飞来的高度(雷达给出的高度数据是 ≤50000的正整数),计算这套系统最多能拦截多少导弹,如果要拦截所有导弹最少要配备多少套这种导弹拦截系统。输入格式1行,若干个整数(个数≤100000)输出格式2行,每行一个整原创 2021-02-09 22:37:56 · 81 阅读 · 0 评论 -
最长上升子序列(优化)
思路f[i]以第i个数结尾的最长上升子序列的长度每一个上升子序列包括自己,将每一个值初始化为1,之后遍历之前的值,如果该值大于之前的值,则比较是现在的值大还是之前某个值加1大。最后答案不是为f数组的最后一个数,因为最长上升子序列不一定以最后一个数为结尾。转移方程if(w[i]>w[j])f[i]=max(f[j]+1,f[i])代码#include<iostream>#include<algorithm>#include<cstdio>using原创 2021-02-09 21:09:50 · 1101 阅读 · 2 评论 -
HDU 1231 最大连续子序列
HDU 1231 最大连续子序列Problem Description给定K个整数的序列{ N1, N2, …, NK },其任意连续子序列可表示为{ Ni, Ni+1, …,Nj },其中 1 <= i <= j <= K。最大连续子序列是所有连续子序列中元素和最大的一个,例如给定序列{ -2, 11, -4, 13, -5, -2 },其最大连续子序列为{ 11, -4, 13 },最大和为20。在今年的数据结构考卷中,要求编写程序得到最大和,现在增加一个要求,即还需要输出原创 2021-02-03 17:30:26 · 118 阅读 · 0 评论 -
luoguP1115 最大子段和
luoguP1115 最大子段和题目描述给出一个长度为 nn 的序列 aa,选出其中连续且非空的一段使得这段和最大。输入格式第一行是一个整数,表示序列的长度 n。第二行有 n个整数,第 i个整数表示序列的第 i个数字 ai 。输出格式输出一行一个整数表示答案。输入样例72 -4 3 -1 2 -4 3输出样例4思路将前n项累加,若大于0,则继续。否则从0开始,因为求最大子段和,如果前面的是负数,加上后一个数会是后一个数变小代码#include<bits/stdc++.h原创 2021-02-02 19:19:00 · 116 阅读 · 0 评论