subject

Cho một dãy có N số lần lượt là a1, a2, …., aN. Với hai phần tử bất kì đứng kề nhau ta tính hiệu của chúng (ai+1 - ai với 0
được với nhau thành một con số gọi là tổng chênh lệch của dãy số.

Yêu cầu: Hãy tìm cách sắp xếp dãy số sao cho có tổng chênh lệch là lớn nhất.

Dữ liệu vào: Từ file văn bản NUMARR. INP

 Dòng đầu tiên: ghi số nguyên dương N (N≤106)  Dòng thứ hai: ghi các số nguyên dương ai (ai ≤1018), mỗi số cách nhau một

khoảng trống

Dữ liệu ra: Ghi vào file văn bản NUMARR. OUT một số nguyên là tổng chênh lệch

lớn nhất của dãy số.

Ví dụ:

NUMARR. INP

5

4 7 3 15 9
NUMARR. OUT
12

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 17:30
How do you make a lenny face? plz, brailiest to who can answer first.
Answers: 1
question
Computers and Technology, 22.06.2019 19:30
When creating a presentation in libre office impress, where does the editing of slides take place? a. the slides panel b. the center panel c. the tasks panel, under the masters pages tab d. the tasks panel, under the layouts tab
Answers: 3
question
Computers and Technology, 23.06.2019 19:30
Anul 2017 tocmai s-a încheiat, suntem trişti deoarece era număr prim, însă avem şi o veste bună, anul 2018 este produs de două numere prime, 2 şi 1009. dorel, un adevărat colecţionar de numere prime, şi-a pus întrebarea: “câte numere dintr-un interval [a,b] se pot scrie ca produs de două numere prime? “.
Answers: 1
question
Computers and Technology, 24.06.2019 01:00
Verify each identity[tex] \frac{csc}{cot \: x \: + \: tan \: x} = cos \: x[/tex]
Answers: 1
You know the right answer?
Cho một dãy có N số lần lượt là a1, a2, …., aN. Với hai phần tử bất kì đứng kề nhau ta tính hiệu củ...
Questions
question
History, 26.03.2021 20:30
question
Mathematics, 26.03.2021 20:30
Questions on the website: 13722359