摘要: 注意数组下标及因下标为负值而造成的数组越界问题。 #include<cstdio> #include<iostream> #include<cstring> using namespace std; const int N=1000005; string s; int f[N],ans; int m 阅读全文
posted @ 2021-09-28 23:03 dfydn 阅读(26) 评论(0) 推荐(0) 编辑
摘要: 用O(n^2)的做法来做,可以确定以每个点为结尾的最长上升/下降子序列,注意最后两个子序列相加时枚举的断点会被统计两次,所以需要减一。 #include<cstdio> #include<iostream> #include<cstring> using namespace std; const i 阅读全文
posted @ 2021-09-28 23:01 dfydn 阅读(34) 评论(0) 推荐(0) 编辑
摘要: 注意要倒序。 设f[i]表示从第i时刻到第n时刻的最大休闲时间。 ```cpp #include<cstdio> #include<iostream> #include<vector> using namespace std; const int N=10005; int f[N]; int cnt 阅读全文
posted @ 2021-09-28 22:59 dfydn 阅读(32) 评论(0) 推荐(0) 编辑
摘要: nlogn解决最长上升/不下降/下降/不上升子序列问题。 设f[len]表示子序列长度为len时序列最后一个数是什么。 那么可以根据具体情况来讨论,一种是直接++len,将其存在数列最后,另一种是用更优的更新不优的。 此题中第一问不难看出是求一个最长不下降子序列,而第二问,相当于求一个最长上升子序列 阅读全文
posted @ 2021-09-28 22:54 dfydn 阅读(69) 评论(0) 推荐(0) 编辑
摘要: https://atcoder.jp/contests/abc220/tasks/abc220_d 设f[i][j]表示拿出要操作的数之后剩余长度为i,在序列外的数为j的方案数,进行记忆化搜索。 注意因为f[i][j]中可能存0,所以f[][]之前没有搜索过的标志不能为f[i][j]=0,==应该将 阅读全文
posted @ 2021-09-28 22:45 dfydn 阅读(101) 评论(0) 推荐(0) 编辑