当前位置:网站首页>D29:post Office (post office, translation)
D29:post Office (post office, translation)
2022-07-03 23:14:00 【Aggressive Wenwen】
The original title is :OpenJudge - 162:Post Office
translate :
describe : There is a straight road , There are villages beside the road . The highway is expressed as an integer axis , The location of each village is identified by a single integer coordinate . The village is in different positions . The distance between two positions is the absolute value of the difference between their integer coordinates .
Post offices will be built in some villages , But not all villages . The location of a village is the same as the post office inside . To build a post office , You should choose their location , Minimize the total distance between each village and its nearest post office .
To write a program , Given the location of the village and the number of post offices , Calculate the minimum possible sum of all distances between each village and its nearest post office ;
Input : Input is read from standard input . The first line contains two integers : The first line is the number of villages V,1 <= V <= 300, The second line is the number of post offices P,1 <= P <= 30,P <= V, The second line contains V It's an integer , The order is increasing . these V The integer is the location of the village . For each location X, It said 1 <= X <= 10000;
Output : An integer S, Represents the sum of all distances between each village and its nearest post office .
边栏推荐
- Ningde times and BYD have refuted rumors one after another. Why does someone always want to harm domestic brands?
- Introduction to the gtid mode of MySQL master-slave replication
- Sow of PMP
- Leetcode: a single element in an ordered array
- C summary of knowledge point definitions, summary notes
- Simple solution of m3u8 file format
- The reason why the computer runs slowly and how to solve it
- [15th issue] Tencent PCG background development internship I, II and III (OC)
- Teach you to easily learn the type of data stored in the database (a must see for getting started with the database)
- webAssembly
猜你喜欢

Exclusive download! Alibaba cloud native brings 10 + technical experts to bring "new possibilities of cloud native and cloud future"

Leetcode: a single element in an ordered array

Hcip day 12 notes
![[Android reverse] application data directory (files data directory | lib application built-in so dynamic library directory | databases SQLite3 database directory | cache directory)](/img/b8/e2a59772d009b6ee262fb4807f2cd2.jpg)
[Android reverse] application data directory (files data directory | lib application built-in so dynamic library directory | databases SQLite3 database directory | cache directory)

Qtoolbutton - menu and popup mode
![[Android reverse] use DB browser to view and modify SQLite database (download DB browser installation package | install DB browser tool)](/img/1d/044e81258db86cf34eddd3b8f5cf90.jpg)
[Android reverse] use DB browser to view and modify SQLite database (download DB browser installation package | install DB browser tool)

The 2022 global software R & D technology conference was released, and world-class masters such as Turing prize winners attended

Shell script three swordsman awk

2022 a special equipment related management (elevator) examination questions and a special equipment related management (elevator) examination contents

Wisdom tooth technology announced that it had completed the round D financing of US $100million and had not obtained a valid patent yet
随机推荐
File copy method
Can you draw with turtle?
Learning notes of raspberry pie 4B - IO communication (SPI)
Wisdom tooth technology announced that it had completed the round D financing of US $100million and had not obtained a valid patent yet
33 restrict the input of qlineedit control (verifier)
. Net ADO splicing SQL statement with parameters
C summary of knowledge point definitions, summary notes
Format cluster and start cluster
The 2022 global software R & D technology conference was released, and world-class masters such as Turing prize winners attended
Pyqt5 sensitive word detection tool production, operator's Gospel
Hcip day 12 notes
1 Introduction to spark Foundation
Text replacement demo
2022 t elevator repair registration examination and the latest analysis of T elevator repair
How to understand the gain bandwidth product operational amplifier gain
2022.02.14
How to switch between dual graphics cards of notebook computer
Fluent learning (4) listview
Programming language (1)
IO flow review