摘要: D - Pair of Topics 思路: 这个题需要一点思路,ai+aj>bi+bj可以转换成ai-bi+aj-bj>0,也就是c[i]=a[i]-b[i],只需要找c[i]+c[j]大于0 一开始的想法是枚举i和j,但是很显然会超时 a和b数组内部的顺序不会影响正确答案个数,所以可以排序 从两 阅读全文
posted @ 2020-03-15 23:12 PCDL&TIPO 阅读(153) 评论(0) 推荐(0) 编辑
摘要: C - Frog Jumps 思路:青蛙跳的问题,青蛙只能跳'R',不能跳'L',问青蛙至少跳多少可以跳过,我们可以这么想这个问题,找到所有R之间的L,看看哪个L多,计算数量即可 代码: #include<iostream> #include<string> #include<cmath> #inc 阅读全文
posted @ 2020-03-15 23:04 PCDL&TIPO 阅读(227) 评论(0) 推荐(0) 编辑
摘要: B - Yet Another Palindrome Problem 思路: 给一个长为n(≤5000≤5000)的数组,问是否存在一个长度至少为3的子序列是回文的。回文的定义是把序列reverse,序列不变,如[10,20,10]就是回文的。 考虑奇数长度的回文序列,删除其首尾元素仍然回文;再考虑 阅读全文
posted @ 2020-03-15 18:17 PCDL&TIPO 阅读(213) 评论(0) 推荐(1) 编辑
摘要: A - Yet Another Tetris Problem 思路:判读一堆数字是不是同奇数偶数,写一个函数,循环遍历,然后判断是否同为奇数偶数。 代码: #include<iostream> using namespace std; int a[1005]; int fun(int n){ int 阅读全文
posted @ 2020-03-15 18:07 PCDL&TIPO 阅读(144) 评论(0) 推荐(1) 编辑