当前位置:网站首页>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 .
边栏推荐
- 1 Introduction to spark Foundation
- The difference between SRAM and DRAM
- How the computer flushes the local DNS cache
- How to quickly build high availability of service discovery
- 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
- Runtime. getRuntime(). totalMemory/maxMemory()
- Loop compensation - explanation and calculation of first-order, second-order and op amp compensation
- Unique in China! Alibaba cloud container service enters the Forrester leader quadrant
- What are the securities companies with the lowest Commission for stock account opening? Would you recommend it? Is it safe to open an account on your mobile phone
- Teach you how to run two or more MySQL databases at the same time in one system
猜你喜欢

Blue Bridge Cup -- Mason prime

IDENTITY

Unique in China! Alibaba cloud container service enters the Forrester leader quadrant

Programming language (1)

Leetcode: a single element in an ordered array

Opengauss database log management guide

In 2022, 6G development has indeed warmed up

Blue Bridge Cup -- guess age

Recursive least square adjustment

Exclusive download! Alibaba cloud native brings 10 + technical experts to bring "new possibilities of cloud native and cloud future"
随机推荐
Qtoolbutton - menu and popup mode
EPF: a fuzzy testing framework for network protocols based on evolution, protocol awareness and coverage guidance
How to switch between dual graphics cards of notebook computer
[untitled]
33 restrict the input of qlineedit control (verifier)
Ningde times and BYD have refuted rumors one after another. Why does someone always want to harm domestic brands?
Qtoolbutton available signal
Unsafe and CAS principle
股票开户最低佣金炒股开户免费,网上开户安全吗
IDENTITY
How to quickly build high availability of service discovery
Hcip day 14 notes
Format cluster and start cluster
Recursion and recursion
SDMU OJ#P19. Stock trading
Go Technology Daily (2022-02-13) - Summary of experience in database storage selection
Pandaoxi's video
C deep anatomy - the concept of keywords and variables # dry inventory #
JarPath
pycuda._ driver. LogicError: explicit_ context_ dependent failed: invalid device context - no currently