其他 贪心
Yishui_Blog
Try our best
展开
-
洛谷 P1417 烹调方案 (01背包+贪心
题意:明显的一个背包问题,题写的太少了,唉, 但是它的价值是与ttt有关的,然后 ttt又是不断变化的,在看了题解以后 我们对相邻的两个任务进行化简会发现价值的变化只和 bbb,ccc相乘的关系有关, 相乘即可xc∗yb&lt;yc∗xbx_c*y_b&lt;y_c*x_bxc∗yb<yc∗xb我们还可以发现一个小小的问题, 时间虽然越靠后 做得的0...原创 2018-10-09 17:23:31 · 165 阅读 · 0 评论 -
Codeforces #304 (Div. 2) B. Soldier and Badges ( 贪心
B. Soldier and Badges 题目描述Colonel has n badges. He wants to give one badge to every of his n soldiers. Each badge has a coolness factor, which shows how much it’s owner reached. Coolness factor ...原创 2018-03-22 22:58:58 · 204 阅读 · 0 评论 -
Codeforces #253 (Div. 1)C. Artem and Array ( 贪心
C. Artem and Array 题目描述Artem has an array of n positive integers. Artem decided to play with it. The game consists of n moves. Each move goes like this. Artem chooses some element of the array and...原创 2018-03-10 21:25:56 · 263 阅读 · 0 评论 -
Codeforces Educational 38 B. Run For Your Prize
题目描述You and your friend are participating in a TV show “Run For Your Prize”.At the start of the show n prizes are located on a straight line. i-th prize is located at position ai. Positions of all...原创 2018-02-18 03:44:01 · 392 阅读 · 0 评论 -
Codeforces 496 E. Distributing Parts ( STL维护贪心
题目描述You are an assistant director in a new musical play. The play consists of n musical parts, each part must be performed by exactly one actor. After the casting the director chose m actors who can...原创 2018-02-13 01:05:21 · 437 阅读 · 0 评论 -
牛客练习赛6 D.世界上最可爱的珂朵莉 ( 贪心
D.世界上最可爱的珂朵莉 题目描述我永远喜欢珂朵莉~! 有两个长为n的序列a[i]与b[i] 你可以把任意不多于x个a序列中的数变成y 你可以把所有序列b中的数减去一个非负数t 你可以把a序列和b序列分别任意打乱 要求对于1 <= i <= n满足a[i] >= b[i] 求t的最小值输入第一行三个数n,x,y 之后一行n个数表示a序列 之后一行...原创 2018-02-26 10:12:56 · 308 阅读 · 0 评论 -
HDUoj 4268 Alice and Bob ( STL二分贪心
题目描述Alice and Bob’s game never ends. Today, they introduce a new game. In this game, both of them have N different rectangular cards respectively. Alice wants to use his cards to cover Bob’s. The card原创 2018-01-23 17:37:23 · 492 阅读 · 0 评论 -
ICPC2017南宁邀请赛1004&&HDU6188 (贪心
Duizi and ShunziDescriptionNike 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 intege原创 2017-09-19 13:58:53 · 581 阅读 · 0 评论 -
Poj-3253-Fence Repair ( 哈夫曼
Fence Repair DescriptionFarmer John wants to repair a small length of the fence around the pasture. He measures the fence and finds that he needs N (1 ≤ N ≤ 20,000) planks of wood, each having some int原创 2017-06-10 00:34:12 · 261 阅读 · 0 评论 -
SGU - 195 New Year Bonus Grant ( 贪心
New Year Bonus Grant 题目描述All programmers of Mocrosoft software company are organized in a strict subordination hierarchy. Every programmer has exactly one chief, except Bill Hates who is also the...原创 2018-03-26 22:42:56 · 144 阅读 · 0 评论 -
洛谷 P1090 合并果子 ( 简单贪心
很简单的贪心,用优先队列维护一下就行了AC代码#include <bits/stdc++.h>using namespace std;const int INF = 0x3f3f3f3f;const int MAXN = 1e6+10;int trie[MAXN][2];const int mod = 998244353;int main() { i...原创 2018-04-07 01:20:56 · 350 阅读 · 0 评论 -
HDU - 6409 没有兄弟的舞会 ( STL
题意:考虑对每个节点维护一个set 标记 然后就是维护最大最小值 xjb搞搞#include <bits/stdc++.h>using namespace std;#define cpp_io() {ios::sync_with_stdio(false); cin.tie(NULL);}#define rep(i,a,n) for (int i=a;i<n;i++)...原创 2018-10-08 22:06:00 · 697 阅读 · 0 评论 -
CodeForces - 140C New Year Snowmen (贪心+堆
题意: 一组数字 找出最多的三个严格单调的数字为一组, 求出最多可以分配多数组?考虑贪心: 数量越多的数组当然是越先考虑组成,数组动态的改变,用大顶堆进行维护#include <bits/stdc++.h>using namespace std;#define ll long long#define CLR(a,b) memset(a,(b),sizeof(a))...原创 2018-07-14 14:59:45 · 280 阅读 · 0 评论 -
Codeforces 1006B.Polycarp's Practice ( 贪心
题意:n个数,k种划分, 问划分的集合种最大是多少, 输出他们的和,并输出每个数的种类 很简单的一个贪心小问题 排序得到最大的kkk个值 记录位置 输出即可#include <algorithm>#include <cstdio>#include <cstring>#include <iostream>#include &l...原创 2018-07-18 22:16:18 · 185 阅读 · 0 评论 -
51Nod1182 完美字符串
就是统计下字母个数排个序,算是贪心吧,,#include <bits/stdc++.h>using namespace std;#define ls st<<1#define rs st<<1|1#define LL long longconst int MAXN= (int) 26;int arr[MAXN];bool check(...原创 2018-06-28 14:58:48 · 140 阅读 · 0 评论 -
51Nod 1344 走格子
辣鸡水题,忘记开LLwa了一次,,,,#include <bits/stdc++.h>using namespace std;#define ls st<<1#define rs st<<1|1#define LL long longconst int MAXN= (int) 1e6+10;int arr[MAXN];int mai...原创 2018-06-28 14:43:51 · 129 阅读 · 0 评论 -
牛客练习赛16A-字典序最大的子序列 ( 贪心
字典序最大的子序列题目描述、给定字符串s,s只包含小写字母,请求出字典序最大的子序列。 子序列:https://en.wikipedia.org/wiki/Subsequence 字典序:https://en.wikipedia.org/wiki/Lexicographical_order输入一行一个字符串s (1 <= |s| <= 100,000)...原创 2018-05-04 00:31:07 · 239 阅读 · 0 评论 -
2018湘潭校赛D-Fibonacci进制 ( 贪心
Fibonacci进制 题目描述Fibonacci数是非常有名的一个数列,它的公式为 f(n)=f(n-1)+f(n-2),f(0)=1,f(1)=2。 我们可以把任意一个数x表示成若干不相同的Fibonacci数的和, 比如说14 = 13+1 = 8+5+1 = 8+3+2+1。 如果把Fibonacci数列作为数的位权,即f(i)作为第i位的位权,每位的系数只能是0或者1,从而...原创 2018-05-03 01:39:17 · 216 阅读 · 0 评论 -
洛谷 P1181 数列分段Section I (简单贪心
连续的数列 一遍扫过去就行了AC代码// luogu-judger-enable-o2#include <bits/stdc++.h>using namespace std;const int INF = 0x3f3f3f3f;const int MAXN = 1e6+10;int trie[MAXN][2];const int mod = 998244353...原创 2018-04-07 01:22:20 · 569 阅读 · 0 评论 -
AtCoder Grand Contest 013 A-Sorted Arrays ( 贪心
Sorted ArraysDescriptionYou are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-in原创 2017-05-31 18:59:57 · 384 阅读 · 0 评论 -
UESTCoj - 1255- 斓少摘苹果 (贪心
斓少摘苹果Time Limit: 3000/3000MS (Java/Others) Memory Limit: 65535/65535KB (Java/Others)Submit Status 斓少家的院子里有NN棵苹果树,每到秋天树上就会结出FiFi个苹果。苹果成熟的时候,斓少就会跑去摘苹果。斓少摘苹果的方式非常的奇特,每次最多可以选择MM个苹果并摘下来。但是摘下来的苹果两两一定不是原创 2017-04-04 23:48:56 · 464 阅读 · 0 评论 -
Poj 2456 Aggressive cows ( 二分+贪心
Aggressive cows DescriptionFarmer John has built a new long barn, with N (2 <= N <= 100,000) stalls. The stalls are located along a straight line at positions x1,…,xN (0 <= xi <= 1,000,000,000).His C (原创 2017-04-26 13:42:06 · 1001 阅读 · 0 评论 -
HDUoj 5499 SDOI (贪心
SDOITime Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 1105 Accepted Submission(s): 440Problem Description The Annual National Olympic of Infor原创 2017-01-26 15:14:07 · 1338 阅读 · 0 评论 -
CodeForces - 629B Far Relative’s Problem (贪心
B. Far Relative’s Problemtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputFamil Door wants to celebrate his birthday with his friends from Far Far A原创 2017-01-24 23:50:53 · 3470 阅读 · 0 评论 -
HDUoj 1084 What Is Your Grade?( 贪心 水
**What Is Your Grade?**Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 11242 Accepted Submission(s): 3517Problem Description “Point, point原创 2017-01-24 23:27:26 · 324 阅读 · 0 评论 -
HDUoj 1050 Moving Tables(贪心 水
Moving TablesTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 33094 Accepted Submission(s): 10914Problem DescriptionThe famous A原创 2017-01-23 21:43:13 · 2387 阅读 · 0 评论 -
Poj 3096 Saruman's Army (贪心
Saruman's ArmyTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 8970 Accepted: 4511DescriptionSaruman the White must lead his army along a straight path原创 2017-01-22 21:00:59 · 212 阅读 · 0 评论 -
HDUoj 1070 Milk(简单贪心
MilkTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 20880 Accepted Submission(s): 5558Problem DescriptionIgnatius drinks milk e原创 2017-01-17 20:30:45 · 387 阅读 · 0 评论 -
HDOJ 2037 今年暑假不AC(第一道贪心)
今年暑假不ACTime Limit: 1000MS Memory Limit: 32768KB 64bit IO Format: %I64d & %I64uSubmitStatus Description“今年暑假不AC?” “是的。” “那你干什么呢?” “看世界杯呀,笨蛋!” “@#$%^&原创 2016-11-21 13:19:04 · 468 阅读 · 0 评论 -
HPUoj魏好看买折纸
问题 B: 魏好看买折纸时间限制: 1 Sec 内存限制: 128 MB提交: - 解决: - 题目描述魏好看在折小红花的过程中,发现自己有折纸的天赋,所以决定去买更多的折纸。她发现商店有各种各样颜色的折纸,魏好看挑不出自己喜欢的种类。为了能拥有更多颜色的折纸,所以她决定买尽量多种类的折纸。然而魏好看这次又发现自己带的钱不多,所以她想知道在能购买尽量多种类折纸的情况原创 2017-01-02 00:41:42 · 415 阅读 · 2 评论 -
Codeforces 699 C. Vacations ( 贪心
C. Vacationstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasy原创 2017-02-04 07:09:42 · 276 阅读 · 0 评论 -
Codeforces #404 (Div. 2) B. Anton and Classes (贪心
B. Anton and Classestime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAnton likes to play chess. Also he likes to do programming. No wonder that he d原创 2017-03-17 17:45:43 · 771 阅读 · 0 评论 -
51Nod 1432 独木舟 (贪心
1432 独木舟Descriptionn个人,已知每个人体重。独木舟承重固定,每只独木舟最多坐两个人,可以坐一个人或者两个人。显然要求总重量不超过独木舟承重,假设每个人体重也不超过独木舟承重,问最少需要几只独木舟?Input第一行包含两个正整数n (0Output一行一个整数表示最少需要的独木舟数。Sample Input3 6123Sample Output2题解:明确思路后就会发现比较水的原创 2017-04-25 18:35:20 · 277 阅读 · 0 评论 -
51Nod 1428 活动安排问题 (贪心
1428 活动安排问题Description有若干个活动,第i个开始时间和结束时间是[Si,fi),同一个教室安排的活动之间不能交叠,求要安排所有活动,最少需要几个教室? Input第一行一个正整数n (n <= 10000)代表活动的个数。 第二行到第(n + 1)行包含n个开始时间和结束时间。 开始时间严格小于结束时间,并且时间都是非负整数,小于1000000000Output一行包含一个整原创 2017-04-25 18:22:36 · 415 阅读 · 0 评论 -
51Nod 1163 最高的奖励 ( 贪心
1163 最高的奖励Description有N个任务,每个任务有一个最晚结束时间以及一个对应的奖励。在结束时间之前完成该任务,就可以获得对应的奖励。完成每一个任务所需的时间都是1个单位时间。有时候完成所有任务是不可能的,因为时间上可能会有冲突,这需要你来取舍。求能够获得的最高奖励。Input第1行:一个数N,表示任务的数量(2 <= N <= 50000) 第2 - N + 1行,每行2个数,中间原创 2017-04-25 01:06:16 · 545 阅读 · 0 评论 -
HDUoj 4004 The Frog's Games ( 二分
The Frog’s Games DescriptionThe annual Games in frogs’ kingdom started again. The most famous game is the Ironfrog Triathlon. One test in the Ironfrog Triathlon is jumping. This project requires the fr原创 2017-05-01 23:05:46 · 373 阅读 · 0 评论 -
51Nod 1133 不重叠的线段 (区间贪心
1133 不重叠的线段基准时间限制:1 秒 空间限制:131072 KB 分值: 10 难度:2级算法题 收藏 关注 X轴上有N条线段,每条线段有1个起点S和终点E。最多能够选出多少条互不重叠的线段。(注:起点或终点重叠,不算重叠)。 例如:[1 5][2 3][3 6],可以选[2 3][3 6],这2条线段互不重叠。 Input 第1行:1个数N,线段的数量(2 <= N <= 100原创 2017-03-17 00:24:16 · 1109 阅读 · 0 评论 -
51Nod 1091 线段的重叠 (区间贪心
1091 线段的重叠基准时间限制:1 秒 空间限制:131072 KB 分值: 5 难度:1级算法题 收藏 关注 X轴上有N条线段,每条线段包括1个起点和终点。线段的重叠是这样来算的,[10 20]和[12 25]的重叠部分为[12 20]。 给出N条线段的起点和终点,从中选出2条线段,这两条线段的重叠部分是最长的。输出这个最长的距离。如果没有重叠,输出0。 Input 第1行:线段的数量原创 2017-03-16 23:43:41 · 383 阅读 · 0 评论 -
Codeforces #297 (Div. 2) B. Pasha and String (贪心
B. Pasha and Stringtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPasha got a very beautiful string s for his birthday, the string consists of low原创 2017-03-21 23:34:45 · 314 阅读 · 0 评论 -
Codeforces #297 (Div. 2) C. Ilya and Sticks(贪心
C. Ilya and Stickstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn the evening, after the contest Ilya was bored, and he really felt like maximiz原创 2017-03-21 23:39:10 · 325 阅读 · 0 评论