Estimation 估算的问题

Problem Description
“There are too many numbers here!” your boss bellows. “How am I supposed to make sense of all of this? Pare it down! Estimate!”
You are disappointed. It took a lot of work to generate those numbers. But, you’ll do what your boss asks.
You decide to estimate in the following way: You have an array A of numbers. You will partition it into k contiguous sections, which won’t necessarily be of the same size. Then, you’ll use a single number to estimate an entire section. In other words, for your array A of size n, you want to create another array B of size n, which has k contiguous sections. If i and j are in the same section, then B[i]=B[j]. You want to minimize the error, expressed as the sum of the absolute values of the differences (Σ|A[i]-B[i]|).

Input
There will be several test cases in the input. Each test case will begin with two integers on a line, n (1≤n≤2,000) and k (1≤k≤25, k≤n), where n is the size of the array, and k is the number of contiguous sections to use in estimation. The array A will be on the next n lines, one integer per line. Each integer element of A will be in the range from -10,000 to 10,000, inclusive. The input will end with a line with two 0s.

Output
For each test case, output a single integer on its own line, which is the minimum error you can achieve. Output no extra spaces, and do not separate answers with blank lines. All possible inputs yield answers which will fit in a signed 64-bit integer.

Sample Input
7 2
6
5
4
3
2
1
7
0 0

Sample Output
9

Taunt Exposure Estimation 估算的问题
Problem Description The brave knights of Camelot are constantly exposed to French taunting while assaulting the castle occupied by the French. Consequently, the taunting to which they are exposed varies with their distance from the castle during their assault, as well as variations in French taunting activity. We need to estimate the total amount of taunting that they are exposed to during a certain time period. Unfortunately, we only have access to a set of measurements at random times — we do not have a continuous reading — and, because of flaws in our archaic equipment, the measurements of taunting occur at unpredictable intervals. The total amount of taunting will be given by the integral of the taunting intensity during the time period, as held in the observation data file. The amount of random noise, though, is fairly high, so that a simple trapezoid-rule integration is all that is merited. Input A single number, n, specifying the number of data points in the file n pairs of floating point numbers (given in increasing x order), separated by a comma — in other words, a CSV file that could be input for a spreadsheet program [the first number is the x coordinate (time specification), the second is the y coordinate (the radiation reading)] Output A single line of text giving the first and last x values (with two digits to the right of the decimal point), and the computed integral (with four digits to the right of the decimal point), in the fashion shown below (which reflects the data shown in the graph): 0.00 to 365.25: 2099.8021 [A reasonable value for the given input, (shown in the graph above), since the values range around 5 3/4, and 365.25 * 5.75 gives 2100.1875.] Sample Input 9 0.0000, 0.5176 0.9869, 1.000 1.596, 1.114 2.370, 1.006 2.904, 0.8481 3.506, 0.5760 3.996, 0.4775 5.004, 0.3945 6.283, 1.004 Sample Output 0.00 to 6.28: 4.7288
《MySQL 性能优化》之理解 MySQL 体系结构

Python+OpenCV实时图像处理

2020年一线城市程序员工资大调查

python爬取百部电影数据，我分析出了一个残酷的真相
2019年就这么匆匆过去了，就在前几天国家电影局发布了2019年中国电影市场数据，数据显示去年总票房为642.66亿元，同比增长5.4%；国产电影总票房411.75亿元，同比增长8.65%，市场占比 64.07%；城市院线观影人次17.27亿，同比增长0.64%。 看上去似乎是一片大好对不对？不过作为一名严谨求实的数据分析师，我从官方数据中看出了一点端倪：国产票房增幅都已经高达8.65%了，为什...

Windows可谓是大多数人的生产力工具，集娱乐办公于一体，虽然在程序员这个群体中都说苹果是信仰，但是大部分不都是从Windows过来的，而且现在依然有很多的程序员用Windows。 所以，今天我就把我私藏的Windows必装的软件分享给大家，如果有一个你没有用过甚至没有听过，那你就赚了????，这可都是提升你幸福感的高效率生产力工具哦！ 走起！???? NO、1 ScreenToGif 屏幕，摄像头和白板...

AI 没让人类失业，搞 AI 的人先失业了

2020年，冯唐49岁：我给20、30岁IT职场年轻人的建议

B站是个宝，谁用谁知道???? 作为一名大学生，你必须掌握的一项能力就是自学能力，很多看起来很牛X的人，你可以了解下，人家私底下一定是花大量的时间自学的，你可能会说，我也想学习啊，可是嘞，该学习啥嘞，不怕告诉你，互联网时代，最不缺的就是学习资源，最宝贵的是啥？ 你可能会说是时间，不，不是时间，而是你的注意力，懂了吧！ 那么，你说学习资源多，我咋不知道，那今天我就告诉你一个你必须知道的学习的地方，人称...

【蘑菇街技术部年会】程序员与女神共舞，鼻血再次没止住。（文末内推）

Java校招入职华为，半年后我跑路了

​两年前不知如何编写代码的我，现在是一名人工智能工程师

loonggg读完需要5分钟速读仅需 2 分钟大家好，我是你们的校长。我知道大家在家里都憋坏了，大家可能相对于封闭在家里“坐月子”，更希望能够早日上班。今天我带着大家换个思路来聊一个问题...

&lt;!DOCTYPE html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;meta charset="UTF-8"&gt; &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt; &lt;meta http-equiv="X...
Spring框架|JdbcTemplate介绍

2020年2月中国编程语言排行榜

B 站上有哪些很好的学习资源?

24岁的程序员，还在未来迷茫，不知道能不能买得起房子

2万字Java并发编程面试题合集（含答案，建议收藏）
Java 并发编程 1、在 java 中守护线程和本地线程区别？ 2、线程与进程的区别？ 3、什么是多线程中的上下文切换？ 4、死锁与活锁的区别，死锁与饥饿的区别？ 5、Java 中用到的线程调度算法是什么？ 6、什么是线程组，为什么在 Java 中不推荐使用？ 7、为什么使用 Executor 框架？ 8、在 Java 中 Executor 和 Executors 的区别？ 9...