题目链接: http://codeforces.com/contest/651/problem/D D. Image Preview time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vasya's telephone contains n photos. Photo number 1 is currently opened on…
D. Image Preview 题目连接: http://www.codeforces.com/contest/651/problem/D Description Vasya's telephone contains n photos. Photo number 1 is currently opened on the phone. It is allowed to move left and right to the adjacent photo by swiping finger over…
A. Beru-taxi time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vasiliy lives at point (a, b) of the coordinate plane. He is hurrying up to work so he wants to get out of his house as soon as…
很神奇的一题 看完题解不由惊叹 题意:$n$个神奇宝贝 $a$个普通球 $b$个高级球 普通球抓住$i$神奇宝贝的概率为$u[i]$ 高级球为$p[i]$ 一起用为$u[i]+p[i]-u[i]*p[i]$ 求期望抓到个神奇宝贝个数 $N,a,b\leq2000$ 首先不难想到$O(n^3)$的暴力$DP$ 听说CF的机子可过 我们接下来写如何优化 对于一个凸函数$f(x)$ 我们假设可以通过某种特殊方式获得其的极值和极值点 令$F(x)=f(x)-kx$ 不难发现$F(x)$也是一个凸函数 仍…
传送门 考试自己yyyyyy的乱搞的没过大样例二分+dp二分+dp二分+dp过了606060把我自己都吓到了! 这么说来乱搞跟被卡常的正解比只少101010分? 那我考场不打其他暴力想正解血亏啊. 正解同样是二分+dp. f[i]f[i]f[i]表示i不变且前面全部满足当前要求时最少需要改几个数. 然后用f[i+1]f[i+1]f[i+1]~f[n]f[n]f[n]转移一下就行了. 代码…
C. Mike and Chocolate Thieves time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output Bad news came to Mike's village, some thieves stole a bunch of chocolates from the local factory! Horrible! As…
[学习笔记]wqs二分/DP凸优化 从一个经典问题谈起: 有一个长度为 \(n\) 的序列 \(a\),要求找出恰好 \(k\) 个不相交的连续子序列,使得这 \(k\) 个序列的和最大 \(1 \leq k \leq n \leq 10^5, -10^9 \leq a_i \leq 10^9\) 先假装都会 \(1 \leq k \leq n \leq 1000\) 的 \(dp\) 做法以及 \(k = 1\) 的子问题 实际上这个问题还可以是个费用流模型: 对于序列中每一个点 \(i\)…
HDU 3433 A Task Process Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1368    Accepted Submission(s): 684 Problem Description There are two kinds of tasks, namely A and B. There are N workers…
题目链接:http://codeforces.com/contest/219/problem/D 树dp //#pragma comment(linker, "/STACK:102400000, 102400000") #include <algorithm> #include <iostream> #include <cstdlib> #include <cstring> #include <cstdio> #include…
A Task Process Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1332    Accepted Submission(s): 656 Problem Description There are two kinds of tasks, namely A and B. There are N workers and the…