[CF878E]Numbers on the blackboard】的更多相关文章

[CF878E]Numbers on the blackboard 题意:给你一个长度为n个数列,你每次可以进行如下操作: 选取两个相邻的数x,y(x在y左面),然后将这两个数去掉,用x+2y替换它. 重复此操作直到序列中只有一个数为止.你可以任意决定每次合并哪两个数,求最后得到的数的最大值. 为了加大难度,现有q次询问,每次询问给出l,r,问你对[l,r]这段区间进行操作能得到的最大值是什么. n,q<=100000,ai<=10^9 题解:先不考虑l,r的限制,整个操作可以看成:让你最大化…
Codeforces 878 E. Numbers on the blackboard 解题思路 有一种最优策略是每次选择最后面一个大于等于 \(0\) 的元素进行合并,这样做完以后相当于给这个元素乘 \(2\) ,并且不使前面一个元素的值增加了.但是按照这样的策略做不太好维护,考虑做完以后有许多块,除了第一个块以外每一个块都是负的,然后将这些块与第一个块合并.那么用并查集维护一下每个块,每一个元素被乘 \(2\) 的次数就是这个块里面位置比它小的元素个数.定义一个块的和为每个元素乘上其对应系数…
LINK:Numbers on the blackboard 看完题觉得很难. 想了一会发现有点水 又想了一下发现有点困难. 最终想到了 但是实现的时候 也很难. 先观察题目中的这个形式 使得前后两个数字变成x+2y. 那么一个数字的变成两倍的次数固定 除了左端点至少可以变化一次. 有些数字 可以变换多次 这取决于什么 容易考虑到右端点 先变化一次 如果>0显然 可以和其左边进行合并一下. 然后 可以变换更多次 然后从右到左考虑这个过程就发现是正确的了. 这样 我们得到了一个nm的做法. 容易发…
$n \leq 100000$的数列,数字范围$-1e9,1e9$,现$q \leq 1e5$个每次问在一个区间玩游戏,能得到的最大的数.“游戏”:选相邻两个数$a_x,a_y$,然后把他们删掉,变成$a_x+2a_y$,直到序列中只剩一个数.答案$\mod \ \ 1e9+7$. 单次询问可用贪心解决:首先第一个数系数一定是1,后面的数的系数是$2^k,k\geq 1$且$k$不会比上一个数的$k$多2以上.用一块表示给某个区间分配了系数2,4,8,16,...,也就是这个区间从左到右一个个合…
B. Smallest number Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/55/problem/B Description Recently, Vladimir got bad mark in algebra again. To avoid such unpleasant events in future he decided to train his arithmetic skil…
ZOJ 3529 - A Game Between Alice and Bob Time Limit:5000MS     Memory Limit:262144KB     64bit IO Format:%lld & %llu Description Alice and Bob play the following game. A series of numbers is written on the blackboard. Alice and Bob take turns choosing…
A Game Between Alice and Bob Time Limit: 5 Seconds      Memory Limit: 262144 KB Alice and Bob play the following game. A series of numbers is written on the blackboard. Alice and Bob take turns choosing one of the numbers, and replace it with one of…
Crazy Professor Time limit: 1.0 secondMemory limit: 64 MB Professor Nathan Mathan is crazy about mathematics. For an unknown reason, he started to write on the blackboard all positive integers starting from 1. After writing a new number a, Professor…
题目链接:HDU - 5170GTY's math problem 题目描述 Description GTY is a GodBull who will get an Au in NOI . To have more time to learn algorithm knowledge, he never does his math homework. His math teacher is very unhappy for that, but she can't do anything beca…
GTY's math problem Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 0    Accepted Submission(s): 0 Problem Description GTY is a GodBull who will get an Au in NOI . To have more time to learn alg…