当前位置:网站首页>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 .
边栏推荐
- How can enterprises and developers take advantage of the explosion of cloud native landing?
- How about opening an account at Hengtai securities? Is it safe?
- Introduction to the gtid mode of MySQL master-slave replication
- Ningde times and BYD have refuted rumors one after another. Why does someone always want to harm domestic brands?
- C # basic knowledge (3)
- Cgb2201 preparatory class evening self-study and lecture content
- What are the common computer problems and solutions
- C # basic knowledge (2)
- Design of logic level conversion in high speed circuit
- Simple solution of m3u8 file format
猜你喜欢
To rotate 90 degrees clockwise and modify the video format
Ningde times and BYD have refuted rumors one after another. Why does someone always want to harm domestic brands?
Go Technology Daily (2022-02-13) - Summary of experience in database storage selection
Pyqt5 sensitive word detection tool production, operator's Gospel
Unity shader visualizer shader graph
Can you draw with turtle?
The overseas listing of Shangmei group received feedback, and brands such as Han Shu and Yiye have been notified for many times and received attention
IO flow review
Flutter internationalized Intl
How to connect a laptop to a projector
随机推荐
Take you to master the formatter of visual studio code
Common problems in multi-threaded learning (I) ArrayList under high concurrency and weird hasmap under concurrency
Recursive least square adjustment
Is the controller a single instance or multiple instances? How to ensure the safety of concurrency
Sow of PMP
Unique in China! Alibaba cloud container service enters the Forrester leader quadrant
Get current JVM data
ADB command to get XML
"Learning notes" recursive & recursive
Recursion and recursion
SDMU OJ#P19. Stock trading
How to switch between dual graphics cards of notebook computer
股票开户佣金最低的券商有哪些大家推荐一下,手机上开户安全吗
The first game of the new year, many bug awards submitted
FPGA tutorial and Allegro tutorial - link
Introduction to the gtid mode of MySQL master-slave replication
Wisdom tooth technology announced that it had completed the round D financing of US $100million and had not obtained a valid patent yet
[Android reverse] use the DB browser to view and modify the SQLite database (copy the database file from the Android application data directory | use the DB browser tool to view the data block file)
The reason why the computer runs slowly and how to solve it
Minimum commission for stock account opening. Stock account opening is free. Is online account opening safe