从本质入手,这个东西影响取值的就是相邻两个哪个先取 设f[i][0/1]为前i个(i-1,i)中先取i/i-1的值(这里不算上i的贡献 转移就显然了,注意要先复制-inf #include<iostream> #include<cstdio> using namespace std; const int N=3005; int n,a[N],b[N],c[N],f[N][2]; int main() { scanf("%d",&n); for(int i…
dp[i][0]表示i号兔子先于i-1号兔子喂食,dp[i][1]反过来. 倒着DP D. Dima and Hares time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Dima liked the present he got from Inna very much. He liked the present he got…
CF358D Dima and Hares 洛谷评测传送门 题目描述 Dima liked the present he got from Inna very much. He liked the present he got from Seryozha even more. Dima felt so grateful to Inna about the present that he decided to buy her nn hares. Inna was very happy. She l…
http://codeforces.com/contest/366/problem/D 遍历下界,然后用二分求上界,然后用dfs去判断是否可以. #include <cstdio> #include <cstring> #include <algorithm> #define maxn 10000 using namespace std; int n,m; int head[maxn]; bool vis[maxn]; int e; int pl[maxn],pr[ma…
B. The Festive Evening time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output It's the end of July – the time when a festive evening is held at Jelly Castle! Guests from all over the kingdom gather he…
To stay woke and attentive during classes, Karen needs some coffee! Karen, a coffee aficionado, wants to know the optimal temperature for brewing the perfect cup of coffee. Indeed, she has spent some time reading several recipe books, including the u…
Polycarp is practicing his problem solving skill. He has a list of n problems with difficulties a1,a2,-,an, respectively. His plan is to practice for exactly k days. Each day he has to solve at least one problem from his list. Polycarp solves the pro…
You are given three integers a, b and x. Your task is to construct a binary string s of length n=a+b such that there are exactly a zeroes, exactly b ones and exactly x indices i (where 1≤i<n) such that si≠si+1. It is guaranteed that the answer always…
Little girl Tanya climbs the stairs inside a multi-storey building. Every time Tanya climbs a stairway, she starts counting steps from 1 to the number of steps in this stairway. She speaks every number aloud. For example, if she climbs two stairways,…
题目:http://codeforces.com/problemset/problem/366/E 事实上就是找 n * m 矩阵中数字 x 和 数字 y 的最远距离. 方法參照武森的论文<浅谈信息学中的"0"和"1"> 先约定符号:xi,xj (i,j)是x的下标,当然.矩阵中的值是能够反复的 上面是武森的论文原文.加上我之前的符号约定,我在做点解释: 事实上那个max={四种可能} 更好的写法是: |xi-yi|+|xj-yj|=max((1),…
Polycarp has n coins, the value of the i-th coin is ai. It is guaranteed that all the values are integer powers of 2 (i.e. ai=2d for some non-negative integer number d). Polycarp wants to know answers on q queries. The j-th query is described as inte…