赫he
赫he
全部文章
分类
题解(3)
归档
标签
去牛客网
登录
/
注册
赫he的博客
全部文章
(共53篇)
题解 | #信封嵌套#
按照长度从小到大排序,当长度相同时,按照宽度从大到小排序。在宽度的维度上,动态规划求最长上升子序列的长度为什么能这么做呢?首先,宽度的维度上,动态规划求最长上升子序列 在长度方向上肯定也是 从小到大的。这里面不存在相等的长度,因为本身上升子序列是一种递增的顺序,而如果长度相同了,它的对应的宽度是第减...
2023-06-15
0
185
题解 | #合唱队形#
关键找 第i个,1~i 是一种递增的顺序, i~k是递减的顺序最少几位出列: 找一个i 使得递增序列的长度和递减序列的长度 和最大那就枚举 每个i 作为那个 队形中 最高值的情况。这样i之前就是 求以h[i]为结尾的最长递增子序列的长度,就是求一遍数组的最长子序列,对应的f[i]自然就表示了“h[i...
2023-06-12
0
175
题解 | #拦截导弹#
等价于求两个问题:问题1: 求最长不增(小于等于)子序列的长度方面就是 线性dp问题2: 求 最少可以划分出不增(小于等于)子序列的个数 #include <iostream> #include <set> using namespace std; const int N =...
2023-06-09
0
206
题解 | #最长上升子序列(一)#
#include <iostream> #include <cstring> using namespace std; int dp[1010]; int main() { int n; cin >> n; int arr[n]; ...
2023-06-08
0
168
题解 | #矩阵的最小路径和#
#include <iostream> #include <cstring> using namespace std; const int N = 501; int map[N][N]; int dp[N][N]; //其中 dp[i][j]表示 到位置(i,j)时的最小路...
2023-06-06
0
181
题解 | #最大子矩阵# 枚举
#include <climits> #include <cstdio> #include <iostream> #include <string.h> using namespace std; const int N = 105; int map[N...
2023-06-05
0
170
题解 | #连续子数组最大和#
#include <iostream> using namespace std; const int N = 200010; int dp[N]; //dp[i] 表示数组 1~i满足的最大值 int a[N]; int main() { int n; sc...
2023-06-01
0
168
题解 | #跳台阶扩展问题#
#include <cstdio> #include <iostream> #include <algorithm> #include <cmath> using namespace std; int main() { int n;...
2023-05-31
0
157
题解 | #识别有效的IP地址和掩码并进行分类统计#
#include <iostream> #include <string> #include <sstream> #include <vector> #include <bitset> using namespace std; int ...
2023-05-29
0
171
题解 | #进制转换#
#include <cctype> #include <iostream> #include <string> using namespace std; int main() { string s; cin >> s; str...
2023-05-19
0
154
首页
上一页
1
2
3
4
5
6
下一页
末页