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 04:30
Ryan is working on the layout of her web page. she needs to figure out where her header, navigation bar, text, and images should go. what technique can her?
Answers: 1
question
Computers and Technology, 23.06.2019 04:31
Q14 what is most important for you to choose before you build a network? a. private network b. nos c. network media d. network protocol e. directory service
Answers: 1
question
Computers and Technology, 24.06.2019 10:10
Which view in a presentation program displays a split window showing the slide in the upper half and a blank space in the lower half?
Answers: 1
question
Computers and Technology, 24.06.2019 17:50
You will subnet the network address 172.31.103.0/24. the network has the following requirements: · room-114 lan will require 27 host ip addresses · room-279 lan will require 25 host ip addresses · room-312 lan will require 14 host ip addresses · room-407 lan will require 8 host ip addresses how many subnets are needed in the network topology?
Answers: 2
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, 10.01.2020 20:31
Questions on the website: 13722362