随笔分类 - 基本算法-贪心
摘要:There is given the series of n closed intervals [ai; bi], where i=1,2,...,n. The sum of those intervals may be represented as a sum of closed pairwise
阅读全文
摘要:有两个区间A[a1,b1], B[a2,b2],判断这两个区间有没有交集。我们可以分为两种思维来判断: 给你两个区间[a, b]和[c, d],如果让你求出这两个区间的相交长度,你会怎么做呢? 不出意外的话,大多数同学就会进行分类讨论,看看那个区间在前,那个区间在后,分两种情况,然后对区间相交还是覆
阅读全文
摘要:https://www.luogu.org/problemnew/show/CF1027C include include include include include include include include include include include include include
阅读全文
摘要:"比赛链接" A CSU 1588 现在有n堆果子,第i堆有ai个果子。现在要把这些果子合并成一堆,每次合并的代价是两堆果子的总果子数。求合并所有果子的最小代价。 Input 第一行包含一个整数T(T,greater q 1.把果子都push进q内; 2.当q的size大于1,不断取最小的两个top
阅读全文
摘要:Professor GukiZ is concerned about making his way to school, because massive piles of boxes are blocking his way. In total there are n piles of boxes,
阅读全文
摘要:Polycarp is practicing his problem solving skill. He has a list of n problems with difficulties a1,a2,…,an, respectively. His plan is to practice for
阅读全文
摘要: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
阅读全文
摘要:"链接" 最大的位或 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 3589 Accepted Submission(s): 1369 Pro
阅读全文
摘要:【链接】: "CF" 【题意】:对任意一个数a[i] ,可以对任意 满足 i != j 且 a[i] a[j] && a[i] include include include include include include include include include include includ
阅读全文
摘要:【前驱】: "在指定长度的棍子中找到能组成最大周长三角形的三根棍子" 链接:https://www.nowcoder.com/acm/contest/134/A 来源:牛客网 题目描述 铁子从森林里收集了n根木棍,她开始将它们按顺序的排成一排,从左到右依次为1到n,她回想起 在数学课上老师教她的三角
阅读全文
摘要:【分析】: 需要对物品按 qi pi 的值从小到大排序,因为这样可以保证每次更新的状态值从小到大递增,前面更新过的状态不会影响后面更新的状态。 每件物品有一个限制,只有当你当前现金大于qi的时候才会卖给你。 这题好好想了一下,跟之前做过的一道题有些类似。考虑简化版,有两个物品(p1,q1,v1),(
阅读全文
摘要:饭卡 Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 39562 Accepted Submission(s): 13548 Problem De
阅读全文
摘要:【分析】: 交集是min(b,d)-max(a,c)+1; 【代码】:
阅读全文
摘要:链接:https://www.nowcoder.com/acm/contest/121/C来源:牛客网 题目描述 iko超级超级喜欢吃糖,有一天iko想出去玩,她计划从1点走到N点(按1,2,3,...,n的顺序走),每个点都有一个补给站,第i点的补给站有a[i]颗糖,从i点走到i+1点会消耗掉b[
阅读全文
摘要:时间复杂度O(n) 有n个人,第i个人的重量为w[i],每艘船的最大载重量均为c,且最多只能乘两个人。用最少的船装载所有人。 思路:从最轻的开始考虑,让最轻的和最重的一条船,若超出重量则可判定最重的只能一人一条船
阅读全文
摘要:include include using namespace std; const int MAXN = 2e5+10; int a[MAXN]; int main() { int n,x; long long ans=0; cin n; for(int i=0;i x;a[x]=i;} for(
阅读全文
摘要:``` 链接:https://www.nowcoder.com/acm/contest/84/A 来源:牛客网 【出处】:http://codeforces.com/contest/196/problem/A 【Codeforces Round 124 (Div. 1) A】 题目描述 给定字符串s
阅读全文
摘要:链接:https://www.nowcoder.com/acm/contest/91/A来源:牛客网 最近对抗生成网络(GAN)很火,其中有一种变体WGAN,引入了一种新的距离来提高生成图片的质量。这个距离就是Wasserstein距离,又名铲土距离。 这个问题可以描述如下: 有两堆泥土,每一堆有n
阅读全文
摘要:题目描述 上课的时候总会有一些同学和前后左右的人交头接耳,这是令小学班主任十分头疼的一件事情。不过,班主任小雪发现了一些有趣的现象,当同学们的座次确定下来之后,只有有限的D对同学上课时会交头接耳。同学们在教室中坐成了M行N列,坐在第i行第j列的同学的位置是(i,j),为了方便同学们进出,在教室中设置
阅读全文
摘要:【链接】:https://acm.ecnu.edu.cn/contest/59/problem/A/ A. 打工时不可能打工的 Time limit per test: 2.0 seconds Memory limit: 256 megabytes Time limit per test: 2.0
阅读全文