[Codeforces Round495B] Sonya and Exhibition】的更多相关文章

[题目链接] https://codeforces.com/contest/1004/problem/B [算法] 不难发现 , 最优解一定是01010101.... 时间复杂度 : O(N) [代码] #include<bits/stdc++.h> using namespace std; template <typename T> inline void read(T &x) { T f = ; x = ; char c = getchar(); for (; !isd…
B. Sonya and Exhibition time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Sonya decided to organize an exhibition of flowers. Since the girl likes only roses and lilies, she decided that only…
B. Sonya and Exhibition time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Sonya decided to organize an exhibition of flowers. Since the girl likes only roses and lilies, she decided that only…
C. Sonya and Queries time limit per test:1 second memory limit per test: 256 megabytes input:standard input output: standard output Today Sonya learned about long integers and invited all her friends to share the fun. Sonya has an initially empty mul…
题目链接:http://codeforces.com/problemset/problem/713/A 题意: Sonya 有一个可放置重复元素的集合 multiset, 初始状态为空, 现给予三种类型的操作: + ai : 把 ai 加入到集合 multiset 中, 可能出现重复元素. -  aj : 把 aj 从集合 multiset 中删除, 保证集合中一定存在这个元素. ? s  : 统计集合中现有的元素和模式串 s 匹配的个数.s 是一个 “01” 串, 其中 "0" 代表…
[题目链接] http://codeforces.com/problemset/problem/713/C [题目大意] 给出一个数列,请你经过调整使得其成为严格单调递增的数列,调整就是给某些位置加上或者减去某个数,调整的代价是加上或者减去的数的绝对值之和,请你输出最小代价. [题解] 先考虑这样一个问题,如果是非严格单调递增该如何做,我们会发现每次调整,都是调整某个数字为原先数列中存在的数字,最后才是最优的,所以,我们设DP[i][j]表示前i个数字,最后一个数为原先数列排序后第j大的数字的最…
题目链接:http://codeforces.com/problemset/problem/1151/F 题目大意: 给定长度为 n 的 01 序列,可以对该序列操作 k 次,每次操作可以交换序列中任意两个元素的位置,求进行 k 次操作后 01 序列升序排列的概率. 分析: 每一次操作就是在 n 个数中选2个,因此有 $\binom{n}{2}$ 种,一共有 k 次操作,所以一共有 $\binom{n}{2}^{k}$ 种可能结果,即分母 Q. 对于分子 P,设序列中 0 的个数为 cnt_0,…
C. Sonya and Problem Wihtout a Legend time limit per test 5 seconds memory limit per test 256 megabytes input standard input output standard output Sonya was unable to think of a story for this problem, so here comes the formal description. You are g…
Description Sonya was unable to think of a story for this problem, so here comes the formal description. You are given the array containing n positive integers. At one turn you can pick any element and increase or decrease it by 1. The goal is the ma…
题目链接   Sonya and Problem Wihtout a Legend 题意  给定一个长度为n的序列,你可以对每个元素进行$+1$或$-1$的操作,每次操作代价为$1$. 求把原序列变成严格递增子序列的所需最小花费. 考虑$DP$. 首先比较常见的套路就是把每个$a[i]$减去$i$,然后把这个新的序列升序排序,记为$b[i]$. 这里有个结论:最后操作完成之后的每个数都是$b[i]$中的某个数. 然后就可以$DP$了,令$f[i][j]$为前$i$个数操作之后每个数都小于等于$b…