已注销
已注销
全部文章
分类
题解(12)
归档
标签
去牛客网
登录
/
注册
已注销的博客
有善始者实繁,能克终者盖寡。
全部文章
(共8篇)
UVA-10905-Children's Game
题意:给定n个数,让你将他们重新组合使得它们组成的数字最大。思路:贪心,很容易想到的是按位的首个数字比较大小,相同则往后比,但是写起来好困难。。。正解:将他们用字符串读入,相邻数字只有两种情况,要么a+b,要么b+a,比较二者大小,最后输出即可。AC代码: #include<bits/stdc...
蓝书第一章题解
贪心
2019-08-23
0
507
P1803 凌乱的yyy / 线段覆盖
题意:中文题面,不需要解释。思路:按比赛结束时间从小到大排序。AC代码: #include<bits/stdc++.h> using namespace std; const int maxn = 1e6+10; struct Node{ int s,e; }node[maxn]...
贪心
2019-08-19
0
529
P1094 纪念品分组
题意:中文题面,不需要解释了。思路:将纪念品件数从小到大排序,小的和大的一组,如果超过给定的上限,则大的单独一组。AC代码: #include<bits/stdc++.h> using namespace std; const int maxn = 3e4+10; int a[maxn]...
贪心
2019-08-19
0
457
P1223 排队接水
题意:中文题面,不需要解释了。思路:按时间从小到大排序即可。AC代码: #include<bits/stdc++.h> using namespace std; const int maxn = 1e3+10; struct Node{ int value,index; }nod...
贪心
2019-08-19
0
567
P1208混合牛奶 Mixing Milk
题意:中文题面,不需要解释了。思路:按金钱大小,从小到大排序即可。AC代码: #include<bits/stdc++.h> using namespace std; const int maxn = 5010; struct Node{ int x,y; }node[maxn]...
贪心
2019-08-19
0
451
P1181 数列分段Section I
题意:中文题面,不需要解释了。思路:贪心,对于当前元素只有两种选择 并到其他段上和单独一段。 并到其他段上:和小于M。 单独一段:和大于M。AC代码: #include<bits/stdc++.h> using namespace std; const int maxn = ...
贪心
2019-08-19
0
472
P1090 合并果子
题意:中文题面,不需要解释了。思路:这是一种哈夫曼型贪心,用优先队列即可。AC代码: #include<bits/stdc++.h> using namespace std; const int maxn = 10010; priority_queue<int,vector<...
贪心
2019-08-19
0
405
B. Make Product Equal One
题意:给定一个数组,数组中的每个数可以加1也可以减1,每次加1或减1记为一次,问要使它们连乘起来乘积为1的最小次数。思路:很容易想到的是,如果是负数就变为-1,正数变为1,0不变,注意0变为1与变为-1的代价都是1。统计小于0的个数为cnt1,等于0的个数为cnt0。 如果cnt1是奇数,而且0...
贪心
CodeForces题解
2019-08-19
0
500