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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 14:00, ashley1460
Mr. johnson creates a game in which the players see the world from their avatar’s perspective. what genre of game is this?
Answers: 2
image
Computers and Technology, 22.06.2019 01:00, toottoot42169
What can you find the under the privacy policy section of a shopping website?
Answers: 1
image
Computers and Technology, 22.06.2019 10:20, alcantar28eduin
Print "usernum1 is negative." if usernum1 is less than 0. end with newline. convert usernum2 to 0 if usernum2 is greater than 10. otherwise, print "usernum2 is less than or equal to 10.". end with newline
Answers: 3
image
Computers and Technology, 23.06.2019 02:00, rah45
Which of the following is not a source of sustainable raw materials? a) coal mine b) flick of sheep c) cotton plantation d) line forest.
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 in other subjects: