[Codeforces 1199C]MP3(离散化+二分答案) 题面 给出一个长度为n的序列\(a_i\)和常数I,定义一次操作[l,r]可以把序列中<l的数全部变成l,>r的数全部变成r.每次操作的代价为改变数的个数.问:要让操作后序列里不同数的个数\(k\)满足$n \lceil \log _2 k\rceil \leq 8I $,操作的最小代价 分析 首先把a离散化,这样[l,r]都在\(10^5\)的级别.枚举l,发现r显然有单调性.操作后不同数的个数随r的增大而减小(考虑极端情况l=…
Link 题意: 给出两字符串$a$,$b$及一个序列,要求从前往后按照序列删掉$a$上的字符,问最少删多少使$b$串不为a的子串 思路: 限制低,直接二分答案,即二分序列位置,不断check即可. /** @Date : 2017-05-07 20:26:33 * @FileName: 779D 二分答案.cpp * @Platform: Windows * @Author : Lweleth (SoundEarlf@gmail.com) * @Link : https://github.co…
You have n devices that you want to use simultaneously. The i-th device uses ai units of power per second. This usage is continuous. That is, in λ seconds, the device will use λ·ai units of power. The i-th device currently has bi units of power store…
传送门 二分答案好题. 题意简述:要求支持动态在一个数列队尾加入一个新的数(保证数列单增),查询所有子数列的 最大值减平均值 的最大值. 然而网上一堆高人是用三分做的. 我们先考虑当前的答案有可能由什么构成. 加入最后一个数之前的最大值. 加入最后一个数之后,以最后一个数为最大值的值. 于是问题变成了去求min{(∑j=1iai)+ani+1}min\{\frac{(\sum_{j=1}^ia_i)+a_n}{i+1}\}min{i+1(∑j=1i​ai​)+an​​} 然后令bi=(∑j=1i…
Digital collectible card games have become very popular recently. So Vova decided to try one of these. Vova has n cards in his collection. Each of these cards is characterised by its power pi, magic number ci and level li. Vova wants to build a deck…
题目链接:http://codeforces.com/problemset/problem/779/D 题意:有两个字符串一个初始串一个目标串,有t次机会删除初始串的字符问最多操作几次后刚好凑不成目标串 所得结果减1 其实简单匹配只需要n只要二分查找一下答案那么结果就是n*logn #include <iostream> #include <cstring> #include <string> using namespace std; const int M = 2e5…
题意:给你两个串,S2是S1 的一个子串(可以不连续).给你一个s1字符下标的一个排列,按照这个数列删数,问你最多删到第几个时S2仍是S1 的一个子串. 题解:二分删掉的数.判定函数很好写和单调性也可以维持. 不知道为啥答案要-1..貌似l最终指向删掉以后不再保持性质的第一个数. #define _CRT_SECURE_NO_WARNINGS #include<cstdio> #include<algorithm> #include<iostream> #include…
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her. Sergey gives Nastya the word t and wa…
D. String Game time limit per test:2 seconds memory limit per test:512 megabytes input:standard input output:standard output Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty…
time limit per test 2 seconds memory limit per test 512 megabytes input standard input output standard output Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, b…