![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
dp
龍木
若人生为棋,我愿为卒,漫漫征途,谁曾见我后退半步
展开
-
力扣训练——动态规划
本篇参照大佬博客练习题顺序,代码都是自打的,有些可能不是最优解。70. 爬楼梯class Solution {public: int climbStairs(int n) { int dp[n+10]; dp[1]=1; dp[2]=2; for(int i=3;i<=n;i++) { dp[i]=dp[i-1]+dp[i-2]; } return原创 2021-01-27 08:26:56 · 570 阅读 · 0 评论 -
C. Bouncing Ball
https://codeforces.ml/contest/1457/problem/CYou're creating a game level for some mobile game. The level should contain some number of cells aligned in a row from left to right and numbered with consecutive integers starting from11, and in each cell you.原创 2020-11-29 17:21:20 · 290 阅读 · 0 评论 -
D. Catching Cheaters
https://codeforces.ml/contest/1447/problem/DYou are given two stringsAAandBBrepresenting essays of two students who are suspected cheaters. For any two stringsCC,DDwe define their similarity scoreS(C,D)S(C,D)as4⋅LCS(C,D)−|C|−|D|4⋅LCS(C,D)−|C|−|...原创 2020-11-16 19:42:46 · 240 阅读 · 0 评论 -
C. Chef Monocarp
Chef Monocarp has just putnndishes into an oven. He knows that theii-th dish has its optimal cooking time equal totitiminutes.At anypositive integerminuteTTMonocarp can putno more than onedish out of the oven. If theii-th dish is put out at s...原创 2020-11-06 14:40:36 · 242 阅读 · 0 评论 -
J - Kingdom‘s Power
https://vjudge.net/contest/402960#problem/JAlex is a professional computer game player.These days, Alex is playing a war strategy game. The kingdoms in the world form a rooted tree. Alex's kingdom11is the root of the tree. With his great diplomacy an..原创 2020-10-22 19:46:45 · 333 阅读 · 0 评论 -
C - Decreasing Heights
链接:https://vjudge.net/contest/399019#problem/CYou are playing one famous sandbox game with the three-dimensional world. The map of the world can be represented as a matrix of sizen×mn×m, where the height of the cell(i,j)(i,j)isai,jai,j.You are in t...原创 2020-10-04 18:39:37 · 216 阅读 · 0 评论 -
B - K-periodic Garland
链接:https://vjudge.net/contest/399019#problem/BYou are given a garland consisting ofnnlamps. States of the lamps are represented by the stringssof lengthnn. Theii-th character of the stringsisiequals '0' if theii-th lamp is turned off or '1' if t...原创 2020-10-04 18:38:28 · 234 阅读 · 0 评论 -
B. Orac and Models
链接:https://codeforces.ml/contest/1350/problem/BThere arennmodels in the shop numbered from11tonn, with sizess1,s2,…,sns1,s2,…,sn.Orac will buy some of the models and will arrange them in the order of increasing numbers (i.e. indices, but not size...原创 2020-05-21 16:24:28 · 366 阅读 · 0 评论 -
C 答题卡
牛牛即将要参加考试,他学会了填答题卡。可惜他竖着的答题卡填成了横着的 : (好奇的他想知道对于 n 道题,每道题 n 个选项的答题卡 ( n * n 的矩阵 ),满足横答题卡和竖答题卡图形一致的方案数有多少种。注:每道题只能选择一个选项,即 n * n 的矩阵中只能涂黑 n 个空。求横竖对称的方案数。输入描述:第一行给出 n。输出描述:输出方案数,...原创 2020-05-02 13:04:40 · 568 阅读 · 0 评论 -
E2. Three Blocks Palindrome (hard version)
链接:https://codeforces.ml/contest/1335/problem/E2The only difference between easy and hard versions is constraints.You are given a sequenceaaconsisting ofnnpositive integers.Let's define ath...原创 2020-04-14 17:58:42 · 297 阅读 · 0 评论 -
D. Carousel
链接:https://codeforces.ml/contest/1328/problem/DThe round carousel consists ofnnfigures of animals. Figures are numbered from11tonnin order of the carousel moving. Thus, after thenn-th figure ...原创 2020-03-27 07:53:51 · 489 阅读 · 0 评论 -
E. Sleeping Schedule
链接:https://codeforces.ml/contest/1324/problem/EVova had a pretty weird sleeping schedule. There arehhhours in a day. Vova will sleep exactlynntimes. Theii-th time he will sleep exactly afterai...原创 2020-03-13 08:11:42 · 763 阅读 · 0 评论 -
E2. String Coloring (hard version)
链接:https://codeforces.ml/contest/1296/problem/E2This is a hard version of the problem. The actual problems are different, but the easy version is almost a subtask of the hard version. Note that the ...原创 2020-02-28 16:33:27 · 194 阅读 · 0 评论 -
E1. String Coloring (easy version)
链接:https://codeforces.ml/contest/1296/problem/E1This is an easy version of the problem. The actual problems are different, but the easy version is almost a subtask of the hard version. Note that the...原创 2020-02-28 16:18:50 · 341 阅读 · 0 评论 -
C. Basketball Exercise
链接:https://codeforces.com/contest/1195/problem/CFinally, a basketball court has been opened in SIS, so Demid has decided to hold a basketball exercise session.2⋅n2⋅nstudents have come to Demid's e...原创 2020-02-19 21:43:57 · 225 阅读 · 0 评论 -
B. New Year and Ascent Sequence
链接:https://codeforces.com/contest/1284/problem/BA sequencea=[a1,a2,…,al]a=[a1,a2,…,al]of lengthllhas anascentif there exists a pair of indices(i,j)(i,j)such that1≤i<j≤l1≤i<j≤landai&...原创 2020-02-18 19:24:29 · 270 阅读 · 0 评论 -
F 碎碎念
链接:https://ac.nowcoder.com/acm/contest/3006/F在ACM比赛里,除了CE以外都是有效的提交。每一个提交都会有其评测的结果,或是AC,或是RJ(Rejected,包含各种不通过的情况)。往往一个人上去提交的时候,总有一个队友会坐在边上等着结果。那个人,往往都是只读题不写题的云选手~牛牛战队里也有这样的云选手——牛能。当牛能看到有效提交得到了AC以后,...原创 2020-02-14 06:15:50 · 207 阅读 · 0 评论 -
Comet OJ - Contest #11Business
链接:https://cometoj.com/contest/67/problem/B?problem_id=3796题目描述※ 简洁题意在分隔线下方一张笑盈盈的脸挡住了替罪羊树的去路,那不怀好意的笑容使困倦的银发少女皱了皱眉。「 sgt ,你有多长时间没打理过那些可怜的节点了?恕我直言,你的本体看上去可不是一般的斜。」「只是我今天的\alphaα设得比较大…」替罪羊树辩...原创 2019-09-23 15:46:06 · 179 阅读 · 0 评论 -
[3] 3276 [2017_4]跳房子
题目链接:http://acm.ocrosoft.com/problem.php?cid=1627&pid=15题目描述题目可见:https://www.luogu.org/problemnew/show/P3957跳房子,也叫跳飞机,是一种世界性的儿童游戏,也是中国民间传统的体育游戏之一。跳房子的游戏规则如下:在地面上确定一个起点,然后在起点右侧画n个格子,这些格...原创 2019-07-14 10:45:27 · 274 阅读 · 0 评论 -
问题 F: 股票买卖
题目描述最近越来越多的人都投身股市,阿福也有点心动了。谨记着“股市有风险,入市需谨慎”,阿福决定先来研究一下简化版的股票买卖问题。假设阿福已经准确预测出了某只股票在未来N天的价格,他希望买卖两次,使得获得的利润最高。为了计算简单起见,利润的计算方式为卖出的价格减去买入的价格。同一天可以进行多次买卖。但是在第一次买入之后,必须要先卖出,然后才可以第二次买入。现在,阿福想知道他最多可以...原创 2019-05-16 20:42:53 · 392 阅读 · 0 评论 -
问题 D: 筷子
题目描述A先生有很多双筷子。确切的说应该是很多根,因为筷子的长度不一,很难判断出哪两根是一双的。这天,A先生家里来了K个客人,A先生留下他们吃晚饭。加上A先生,A夫人和他们的孩子小A,共K+3个人。每人需要用一双筷子。A先生只好清理了一下筷子,共N根,长度为T1,T2,T3,……,TN.现在他想用这些筷子组合成K+3双,使每双的筷子长度差的平方和最小。(怎么不是和最小??这要去问A先生了,呵呵...原创 2019-05-16 20:29:56 · 1148 阅读 · 0 评论 -
3343 问题 H: [2015_3]推销员
题目描述阿明是一名推销员,他奉命到螺丝街推销他们公司的产品。螺丝街是一条死胡同,出口与入口是同一个,街道的一侧是围墙,另一侧是住户。螺丝街一共有 N 家住户,第 ii 家住户到入口的距离为 Si 米。由于同一栋房子里可以有多家住户,所以可能有多家住户与入口的距离相等。阿明会从入口进入,依次向螺丝街的 X 家住户推销产品,然后再原路走出去。阿明每走 11 米就会积累 11 点疲劳值,向第 i...原创 2019-05-08 16:04:25 · 643 阅读 · 0 评论 -
3278: [2015_4]求和
题目描述一条狭长的纸带被均匀划分出了n个格子,格子编号从1到n。每个格子上都染了一种颜色color_i用[1,m]当中的一个整数表示),并且写了一个数字number_i。定义一种特殊的三元组:(x,y,z),其中x,y,z都代表纸带上格子的编号,这里的三元组要求满足以下两个条件:xyz是整数,x<y<z,y-x=z-ycolorx=colorz满足上述条件的三...原创 2019-05-08 16:02:34 · 561 阅读 · 0 评论 -
H 施魔法
链接:https://ac.nowcoder.com/acm/contest/3003/H牛可乐有 n 个元素(编号 1..n ),第 i 个元素的能量值为a_iai。牛可乐可以选择至少k 个元素来施放一次魔法,魔法消耗的魔力是这些元素能量值的极差。形式化地,若所用元素编号集合为 S,则消耗的魔力为\max_{i\in S}\{a_i\}-\min_{i\in S}\{a_i\}m...原创 2020-02-07 13:22:30 · 648 阅读 · 0 评论 -
B. Just Eat It!
链接:https://codeforces.com/contest/1285/problem/BToday, Yasser and Adel are at the shop buying cupcakes. There arenncupcake types, arranged from11tonnon the shelf, and there are infinitely many...原创 2020-02-02 14:30:59 · 460 阅读 · 0 评论 -
A. DZY Loves Sequences
链接:https://codeforces.com/contest/446/problem/ADZY has a sequencea, consisting ofnintegers.We'll call a sequenceai, ai + 1, ..., aj(1 ≤ i ≤ j ≤ n)a subsegment of the sequencea. The value(j...原创 2020-01-28 15:14:39 · 203 阅读 · 0 评论 -
C. Number of Ways
链接:https://codeforces.com/contest/466/problem/CYou've got arraya[1], a[2], ..., a[n], consisting ofnintegers. Count the number of ways to split all the elements of the array into three contiguous...原创 2020-01-16 15:28:29 · 160 阅读 · 0 评论 -
C. Two Arrays
链接:https://codeforces.com/contest/1288/problem/CYou are given two integersnnandmm. Calculate the number of pairs of arrays(a,b)(a,b)such that:the length of both arrays is equal tomm; each e...原创 2020-01-15 14:38:38 · 196 阅读 · 0 评论 -
A. Boredom
链接:https://codeforces.com/contest/455/problem/AAlex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a game and decided to pla...原创 2020-01-14 14:47:40 · 144 阅读 · 0 评论 -
E. New Year Parties
链接:https://codeforces.com/contest/1283/problem/EOh, New Year. The time to gather all your friends and reflect on the heartwarming events of the past year...nnfriends live in a city which can be r...原创 2020-01-09 19:16:18 · 363 阅读 · 0 评论 -
E. By Elevator or Stairs?
链接:https://codeforces.com/contest/1249/problem/EYou are planning to buy an apartment in ann-floor building. The floors are numbered from11tonnfrom the bottom to the top. At first for each floor...原创 2019-10-23 16:25:01 · 318 阅读 · 0 评论 -
问题 F: N个物品2
链接:http://acm.ocrosoft.com/problem.php?cid=2001&pid=5题目描述 现有N个物品,第i个物品有两个属性A_i和B_i。在其中选取若干个物品,使得sum{A_i + B_i}最大,同时sum{A_i},sum{B_i}均非负(sum{}表示求和)。输入 第一行,一个整数,表示物品个数N。 接下...原创 2019-10-20 13:00:08 · 434 阅读 · 0 评论