Codeforces 1038D - Slime - [思维题][DP]】的更多相关文章

题目链接:http://codeforces.com/problemset/problem/1038/D 题意: 给出 $n$ 个史莱姆,每个史莱姆有一个价值 $a[i]$,一个史莱姆可以吃掉相邻的史莱姆,此时其自身的价值就要减掉被吃掉的那个史莱姆的价值. 史莱姆会不断的互相吞噬直到最后只剩一个,要求你该史莱姆可能的最大价值. 题解: 相当于你在 $n$ 个数前面添加 $+$ 或者 $-$,然后拼成一个算式计算答案. 首先考虑到的是,史莱姆的价值是全正或者全负的情况,这样的话,不可能使得所有价值…
Online Judge:Luogu-P2160 Label:思维题,Dp,空间优化 题面: 题目描述 给\(N\)本书,每本书有高度\(Hi\),厚度\(Ti\).要摆在一个三层的书架上. 书架的宽是每层书厚度和的最大值.书架的高度是每层最高书的高度之和. 求如何放书,使得书架的面积最小. 输入 第一行一个整数\(n\),表示书本的个数. 接下来\(n\)行,每行2个整数,表示每本书的高度和厚度. 输出 输出一个整数,表示书架的最小面积. 样例 Input 4 220 29 195 20 20…
https://vjudge.net/problem/2135388/origin Describe You are given an integer sequence 1,2,-,n. You have to divide it into two sets A and B in such a way that each element belongs to exactly one set and |sum(A)−sum(B)| is minimum possible. The value |x…
Each month Blake gets the report containing main economic indicators of the company "Blake Technologies". There are n commodities produced by the company. For each of them there is exactly one integer in the final report, that denotes correspond…
Little X used to play a card game called "24 Game", but recently he has found it too easy. So he invented a new game. Initially you have a sequence of n integers: 1, 2, ..., n. In a single step, you can pick two of them, let's denote them a and …
Little Artem is fond of dancing. Most of all dances Artem likes rueda — Cuban dance that is danced by pairs of boys and girls forming a circle and dancing together. More detailed, there are n pairs of boys and girls standing in a circle. Initially, b…
Welcoming autumn evening is the best for walking along the boulevard and npeople decided to do so. The boulevard can be represented as the axis Ox. For every person there are three parameters characterizing the behavior: ti, si, fi — the moment of ti…
Sonya and Robots time limit per test 1 second memory limit per test 256 megabytes input: standard input output: standard output Since Sonya is interested in robotics too, she decided to construct robots that will read and recognize numbers. Sonya has…
Kevin has just recevied his disappointing results on the USA Identification of Cows Olympiad (USAICO) in the form of a binary string of length n. Each character of Kevin's string represents Kevin's score on one of the n questions of the olympiad-'1' …
Neko Performs Cat Furrier TransformCodeForces - 1152B 题目大意:给你一个x,在40步操作以内把x变成2m−1,m为非负整数.对于每步操作,奇数步可以在(0<=n<=30)中挑选一个n,将x⊕(2n−1),而偶数步将x++.输出操作步数,以及在每个奇数步异或的n,多个答案,输出任一答案,保证至少有一个答案. 一开始傻逼了,真的照题意所说的去写了一个深搜,果断超时了.其实每个奇数步也是异或一个二进制全1的数,那我们就直接把x尾部连续0部分,全部…