Computers and Technology

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

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 24.06.2019 00:40, ndurairajownkpq
What social factors affect your health
Answers: 3
image
Computers and Technology, 24.06.2019 01:00, summerjoiner
Verify each identity[tex] \frac{csc}{cot \: x \: + \: tan \: x} = cos \: x[/tex]
Answers: 1
image
Computers and Technology, 24.06.2019 09:00, lisacarter0804
Why might you chose to crest a function resume
Answers: 1
image
Computers and Technology, 24.06.2019 12:30, nomood
Select all that apply. what two keys listed below should you use to enter data in an excel worksheet? tab backspace enter right arrow
Answers: 2
Do you know the correct 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 in other subjects:

Konu
Mathematics, 26.11.2019 03:31
Konu
Mathematics, 26.11.2019 03:31
Konu
Biology, 26.11.2019 03:31