Nhớn lất

View as PDF

Submit solution

Points: 0.01
Time limit: 1.0s
Memory limit: 64M
Input: stdin
Output: stdout

Authors:
Problem type

Nhập vào một mảng ~a~ gồm ~n~ phần tử.

Tìm giá trị lớn nhất của biểu thức sau:

~|a_i - a_j| + |a_j - a_k| + |a_k - a_l| + |a_l - a_i|~

Với ~1 \leq i, j, k, l \leq n~ và ~i, j, k, l~ phân biệt nhau.

Giới hạn
  • ~4 \leq n \leq 100~
  • ~-10^6 \leq a_i \leq 10^6~
Đầu vào
  • Dòng đầu tiên: số nguyên ~n~.
  • Dòng thứ hai: ~n~ số nguyên ~a_i~.
Đầu ra
  • Một số nguyên duy nhất: giá trị lớn nhất của biểu thức.
Sample Input
5
1 2 3 4 5
Sample Output
12

Comments

Please read the guidelines before commenting.


There are no comments at the moment.