# 蒟蒻的Codeforces Round #316 (Div. 2)补题记

A. Elections（模拟）

A题看错题意，没处理好一人都没的票的情况。。。WA了四次，还有一次过了47个点。。。虽说9min就过了C，但是还是直接崩了。

B. Simple Game（博弈论）

C. Replacement（乱搞，讨论）

D. Tree Requests（dfs序+二分）

E. Pig and Palindromes（dp）

E差一点就写完了，就是最后的讨论没写清楚，没出样例于是GG。

# 蒟蒻的Codeforces Round #379 (Div. 2)颓废记

vp了一场，中间被队友叫去填表格耽误了一些时间，E没时间想了，后来看看题解自己推了推感觉还有可能拯救一下？

A. Anton and Danik（模拟）

B. Anton and Digits（模拟）

C. Anton and Making Potions（二分+贪心）

D. Anton and Chess（模拟）

E. Anton and Tree（缩点+树的直径）

F. Anton and School（数学）

F题考察出了我上学期数字逻辑没怎么学好（废话只考了75） ，clearY一眼秒了。我还是看了题解才发现这个性质: .感觉就是个加法器的实现啊。

# hdu 3507 Print Article（斜率优化dp）

Problem Description
Zero has an old printer that doesn’t work well sometimes. As it is antique, he still like to use it to print articles. But it is too old to work for a long time and it will certainly wear and tear, so Zero use a cost to evaluate this degree.
One day Zero want to print an article which has N words, and each word i has a cost Ci to be printed. Also, Zero know that print k words in one line will cost

M is a const number.
Now Zero want to know the minimum cost in order to arrange the article perfectly.

Input
There are many test cases. For each test case, There are two numbers N and M in the first line (0 ≤ n ≤ 500000, 0 ≤ M ≤ 1000). Then, there are N numbers in the next 2 to N + 1 lines. Input are terminated by EOF.

Output
A single number, meaning the mininum cost to print the article.

Sample Input
5 5
5
9
5
7
5

Sample Output
230

，sum数组是前缀和。