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: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 20:00, bartlettcs9817
Which location-sharing service offers items for users as a gaming component and also allows them to collectively link their check-ins to publish a trip? a. whrrl b. buzzd c. foursquare (this option is wrong i already tried) d. gowalla for plato
Answers: 2
image
Computers and Technology, 22.06.2019 21:30, GamerGirl15
This graph compares the total cost of attending educational institutions in texas. the graph demonstrates that the cost at private and public technical schools greatly varies.
Answers: 2
image
Computers and Technology, 23.06.2019 04:00, china236
In a word processing program, such as microsoft word, which feature to you choose the desired picture enhancement?
Answers: 2
image
Computers and Technology, 23.06.2019 13:00, jaelynnm
Donnie does not have powerpoint. which method would be best for elana to save and share her presentation as is? a pdf a doc an rtf a ppt
Answers: 3
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
History, 11.10.2021 01:50
Konu
English, 11.10.2021 01:50
Konu
Mathematics, 11.10.2021 01:50
Konu
Mathematics, 11.10.2021 01:50
Konu
Mathematics, 11.10.2021 01:50