题目链接:https://codeforces.com/contest/1364/problem/B 题意 给出大小为 $n$ 的一个排列 $p$,找出子序列 $s$,使得 $|s_1-s_2|+|s_2-s_3|+\ldots+|s_{k-1}-s_k|$ 最大的同时 $k$ 尽可能地小。 题解 ...
分类:
其他好文 时间:
2020-06-14 18:48:20
阅读次数:
95
地址 https://www.acwing.com/problem/content/description/259/ S 城现有两座监狱,一共关押着 N 名罪犯,编号分别为1~N。 他们之间的关系自然也极不和谐。 很多罪犯之间甚至积怨已久,如果客观条件具备则随时可能爆发冲突。 我们用“怨气值”(一个 ...
题目链接:https://www.acwing.com/problem/content/102/ 给定一个序列,只能对一个区间加一或者减一,问至少需要多少步使得所有数都变成一致的?有多少种一致序列? 利用差分,对一个区间进行加一或者减一的话,一定是一个差分+1加上另一个差分-1。 代码如下: #in ...
分类:
编程语言 时间:
2020-06-14 16:48:39
阅读次数:
71
题目链接:http://poj.org/problem?id=3889 根据对称性以及规律可以分四种情况进行归纳。旋转的情况可以这样考虑, ①、对于位置为(x,y)的点,边长为k的正方形中,顺时针旋转九十度之后的坐标是(y,k-1-x), ②、对于位置(x,y)上的点,边长为k的正方形中,逆时针旋转 ...
分类:
编程语言 时间:
2020-06-14 14:36:53
阅读次数:
56
题目链接:http://poj.org/problem?id=1958 代码: #include<iostream> #include<cstring> using namespace std; #define maxn 100 typedef long long ll; ll d[maxn],f[ ...
分类:
编程语言 时间:
2020-06-14 12:57:40
阅读次数:
82
1045 快速排序 (25分) 求划分的主元(比左边的都大,右边的都小) #include<iostream> #include<vector> #include<cctype> #include<map> #include<set> #include<sstream> #include<strin ...
分类:
编程语言 时间:
2020-06-14 10:28:39
阅读次数:
66
https://darkbzoj.tk/problem/1855 https://www.luogu.com.cn/problem/P2569 单调队列优化,还是看了一眼题解才做出来的/kk $1\leq BP_i\leq AP_i\leq 1000,1\leq AS_i,BS_i\leq\text ...
分类:
其他好文 时间:
2020-06-13 23:27:24
阅读次数:
76
Structural Information Often, the original problem formulation provides more insight into the structure of the problem. This can be exploited while ge ...
分类:
其他好文 时间:
2020-06-13 23:06:07
阅读次数:
78
题目 https://www.luogu.com.cn/problem/P1616 题目分析 完全背包 代码 #include<iostream> #include<cstdio> #include<algorithm> using namespace std; int f[10000002], v ...
分类:
其他好文 时间:
2020-06-13 21:40:53
阅读次数:
63
题目 https://www.luogu.com.cn/problem/P1048 题目分析 01背包 代码 #include<iostream> #include<cstdio> #include<algorithm> using namespace std; int f[1001], v[200 ...
分类:
其他好文 时间:
2020-06-13 21:16:29
阅读次数:
51