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 06:30
This technology is used to produce high-quality documents that look good on the computer screen and in print.
Answers: 1
question
Computers and Technology, 23.06.2019 09:00
Which company provides a crowdsourcing platform for corporate research and development? a: mtruk b: wiki answers c: mediawiki d: innocentive
Answers: 2
question
Computers and Technology, 23.06.2019 11:30
The most accurate readings that you can take on an analog vom are when the meter's pointer is at the a. center scale. b. extreme right. c. near right. d. extreme left.
Answers: 1
question
Computers and Technology, 24.06.2019 09:40
Healthy study habits are best described as
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
Mathematics, 14.11.2020 16:10
question
Mathematics, 14.11.2020 16:10
question
History, 14.11.2020 16:10
question
Mathematics, 14.11.2020 16:10
question
History, 14.11.2020 16:10
question
Health, 14.11.2020 16:10