随笔分类 -  DP

摘要:A DP problem about inversion number between two permutations. 阅读全文
posted @ 2019-11-22 01:52 Pat 阅读(251) 评论(0) 推荐(0)
摘要:设共有 $N = \sum\_{i=1}^{9} A_i$ 个数字。先把 $N$ 个数字任意分成两组 $A$ 和 $B$,$A$ 中有 $N_A = \floor{N/2}$ 个数字,$B$ 中有 $N_B=\ceil{N/2}$ 个数字。将 $A$ 中数字之和记作 $S_A$,$B$ 中数字之和记 阅读全文
posted @ 2019-11-19 17:09 Pat 阅读(468) 评论(0) 推荐(0)
摘要:Problem Statement Let us define the oddness of a permutation \(p = \\{p_1, p_2, \dots, p_n\\}\) of \(\\{1, 2, \dots, n\\}\) as \(\sum_{i=1}^{n} | i - 阅读全文
posted @ 2019-11-11 02:14 Pat 阅读(630) 评论(0) 推荐(1)
摘要:"题目链接" 题目大意 在一条数轴上住着 $N$ 条狗和一个动物研究者 Bundle。Bundle 的坐标是 0,狗的坐标都是正整数,可能有多条狗住在同一个位置。每条狗都有一个颜色。Bundle 需要观测 $K$ 条狗。要观测一条狗 Bundle 必须走到狗的住处,并且穿着和狗同色的衣服。Bundl 阅读全文
posted @ 2019-10-02 03:46 Pat 阅读(270) 评论(0) 推荐(0)
摘要:$\DeclareMathOperator{\sw}{sw}$ $\DeclareMathOperator{\sb}{sb}$ $\DeclareMathOperator{\dp}{dp}$ 用 $\sw[i]$ 表示前 $i$ 个盒子中所有白盒子的权值之和。 用 $\sb[i]$ 表示前 $i$ 阅读全文
posted @ 2018-07-22 09:40 Pat 阅读(471) 评论(0) 推荐(0)
摘要:题目大意 A 国一共有 $n$ 个城市且有 $n 1$ 条双向道路,且任意两个城市都可以通过道路互相到达。 现在 B 国给出了两个城市的集合 $X,Y$,你需要摧毁若干条 A 国的道路,使得任意一个在 X 中的城市无法到达任何一个 Y 中的城市。 现在给定每条道路摧毁需要付出的代价,求一个代价之和最 阅读全文
posted @ 2018-06-11 13:29 Pat 阅读(191) 评论(0) 推荐(0)
摘要:这道题我想了一天才想清楚做法。AC 了之后去看别人写的题解,都是三言两语意识流式描述,我并不能读懂。我觉得很自卑,为何人家解这道题如此轻松。不过,我还是决定把我的解法写下来,并且一定要写清楚。 思路 我想多数人见到这个题目的想法都是:先按照某种方式对三角形排序,再设法 DP 。大方向确实如此。我的做 阅读全文
posted @ 2017-09-30 00:28 Pat 阅读(268) 评论(0) 推荐(0)
摘要:题目大意 给定 $N$ 个矩形的宽和高, $(h_1, w_1), (h_2, w_2), \dots, (h_n w_n)$ . 现需要确定 $k$ ($k \le K$, $K$ 给定) 个矩形 $(H_i, W_i)$ , 使得 $\forall i \ (1\le i\le N), \exi 阅读全文
posted @ 2017-01-04 09:09 Pat 阅读(200) 评论(0) 推荐(0)
摘要:Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Problem Description Hearthstone is an online collectible card game fr 阅读全文
posted @ 2016-08-09 18:30 Pat 阅读(539) 评论(0) 推荐(0)
摘要:传送门 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 在遥远的未来,小Hi成为了地球联邦外空间联合开发工作组的一员,前往一颗新发现的星球开发当地的重金属资源。 为了能够在当地生存下来,小Hi首先要建立一个基地。建立基地的材料可以直接使用当地的石材和富裕的重金属资源。基 阅读全文
posted @ 2016-04-11 22:39 Pat 阅读(341) 评论(0) 推荐(0)
摘要:传送门 总结: 1.仔细读题 2.仔细分析复杂度 3.不要想当然,乱下结论 时间限制:5000ms 单点时限:1000ms 内存限制:256MB 描述 小Hi、小Ho还有被小Hi强拉来的小Z,准备组队参加一个智力竞赛。竞赛采用过关制,共计N个关卡。在第i个关卡中,小Hi他们需要获得Ai点分数才能够进 阅读全文
posted @ 2016-04-08 00:17 Pat 阅读(384) 评论(0) 推荐(0)
摘要:传送门Time Limit: 3000MSDescriptionThere is a magic planet in the space. There is a magical country on the planet. There are N cities in the country. The... 阅读全文
posted @ 2015-10-13 09:36 Pat 阅读(238) 评论(0) 推荐(0)
摘要:传送门 Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Description A school bought the first computer some time ago(so this computer 阅读全文
posted @ 2015-10-13 08:53 Pat 阅读(378) 评论(0) 推荐(0)
摘要:最长上升公共子序列(Longest Increasing Common Subsequence,LICS)也是经典DP问题,是LCS与LIS的混合。Problem求数列 a[1..n], b[1..m]的LICS的长度, a[], b[]数组的元素均为正整数。Solution考虑如何定义DP状态,定... 阅读全文
posted @ 2015-08-19 23:17 Pat 阅读(283) 评论(0) 推荐(0)
摘要:最长公共子序列(LCS)是经典的DP问题,求序列a[1...n], b[1..m]的LCS。状态是DP[i][j],表示a[1..i],b[1..j]的LCS。DP转移方程是DP[i][j]= DP[i-1][j-1]+1, a[i] == b[j] max{ DP[i][j-1], DP[i... 阅读全文
posted @ 2015-08-16 22:36 Pat 阅读(305) 评论(0) 推荐(0)
摘要:传送门 The task is to find the length of the longest subsequence in a given array of integers such that all elements of the subsequence are sorted in asc 阅读全文
posted @ 2015-08-01 20:00 Pat 阅读(407) 评论(0) 推荐(0)