当前位置:网站首页>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 .
边栏推荐
- [15th issue] Tencent PCG background development internship I, II and III (OC)
- Selenium check box
- Introduction to the gtid mode of MySQL master-slave replication
- [automation operation and maintenance novice village] flask-2 certification
- Yyds dry goods inventory Prometheus alarm Art
- Learning notes of raspberry pie 4B - IO communication (SPI)
- [note] glide process and source code analysis
- URLEncoder. Encode and urldecoder Decode processing URL
- How the computer flushes the local DNS cache
- Common problems in multi-threaded learning (I) ArrayList under high concurrency and weird hasmap under concurrency
猜你喜欢

What are the common computer problems and solutions

C deep anatomy - the concept of keywords and variables # dry inventory #

Opengauss database log management guide

Hcip day 16 notes

How to switch between dual graphics cards of notebook computer

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

Overview of Yunxi database executor

Shiftvit uses the precision of swing transformer to outperform the speed of RESNET, and discusses that the success of Vit does not lie in attention!

IDENTITY

Selenium check box
随机推荐
Take you to master the formatter of visual studio code
Label coco format data and format data in the upper left corner and lower right corner are mutually converted
Ningde times and BYD have refuted rumors one after another. Why does someone always want to harm domestic brands?
Pan Yueming helps Germany's Rochester Zodiac custom wristwatch
Les sociétés de valeurs mobilières dont la Commission d'ouverture d'un compte d'actions est la plus faible ont ce que tout le monde recommande.
How to connect a laptop to a projector
2022.02.13
Programming language (2)
Mongoose the table associated with the primary key, and automatically bring out the data of another table
C summary of knowledge point definitions, summary notes
Live app source code, jump to links outside the station or jump to pages inside the platform
Gorilla/mux framework (RK boot): add tracing Middleware
Teach you to easily learn the type of data stored in the database (a must see for getting started with the database)
Hcip day 12 notes
Shiftvit uses the precision of swing transformer to outperform the speed of RESNET, and discusses that the success of Vit does not lie in attention!
C # basic knowledge (2)
540. Single element in ordered array
Ningde times and BYD have refuted rumors one after another. Why does someone always want to harm domestic brands?
pycuda._ driver. LogicError: explicit_ context_ dependent failed: invalid device context - no currently
Leetcode week 4: maximum sum of arrays (shape pressing DP bit operation)