Solutions are presented as using the least memory and the fastest execution time. It also takes the top
10 most recent solutions from each language. If you want to limit to a specific index, click the
"Solved" button and go to that problem.
Problems
B'Sasha decided to give his girlfriend an array a_1, a_2, ldots, a_n . He found out that his girlfriend evaluates the beauty of the array as the sum of the values (a_i - a_{i - 1}) for all integers i from 2 to n . Help Sasha and tell him the maximum beauty of the array a that he can obtain, if he can rearrange its elements in any way. Each test consists of multiple test cases. The first line contains a single integer t ( 1 <= t <= 500 ) -- the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer n ( 2 <= q n <= q 100 ) -- the length of the array a . The second line of each test case contains n integers a_1, a_2, ldots, a_n ( 1 <= q a_i <= q 10^9 ) -- the elements of the array a . For each test case, output a single integer -- the maximum beauty of the array a that can be obtained. In the first test case, the elements of the array a can be rearranged to make a = [1, 2, 3] . Then its beauty will be equal to (a_2 - a_1) + (a_3 - a_2) = (2 - 1) + (3 - 2) = 2 . In the second test case, there is no need to rearrange the elements of the array a . Then its beauty will be equal to 0 . '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
246566263 |
TheBestMrand |
A |
Feb. 15, 2024, 4:58 p.m. |
OK |
C# 10 |
TESTS |
3 |
46 |
2969600 |
|
|
246618015 |
__shuva |
A |
Feb. 16, 2024, 5:02 a.m. |
OK |
C# 10 |
TESTS |
3 |
46 |
3072000 |
|
|
246618395 |
ravinem1 |
A |
Feb. 16, 2024, 5:07 a.m. |
OK |
C# 8 |
TESTS |
3 |
124 |
3584000 |
|
|
246573308 |
mr-70da |
A |
Feb. 15, 2024, 5:40 p.m. |
OK |
Clang++17 Diagnostics |
TESTS |
3 |
264 |
0 |
|
|
246588780 |
Eren_yeager_27 |
A |
Feb. 15, 2024, 8:03 p.m. |
OK |
Clang++17 Diagnostics |
TESTS |
3 |
280 |
0 |
|
|
246576338 |
bumboo_jumboo |
A |
Feb. 15, 2024, 6:03 p.m. |
OK |
Clang++17 Diagnostics |
TESTS |
3 |
280 |
0 |
|
|
246567888 |
Fomalhaut9918 |
A |
Feb. 15, 2024, 5:06 p.m. |
OK |
Clang++20 Diagnostics |
TESTS |
3 |
46 |
0 |
|
|
246568722 |
caonguyen11113333 |
A |
Feb. 15, 2024, 5:10 p.m. |
OK |
Clang++20 Diagnostics |
TESTS |
3 |
280 |
2150400 |
|
|
246567862 |
turjo31 |
A |
Feb. 15, 2024, 5:06 p.m. |
OK |
GNU C11 |
TESTS |
3 |
15 |
0 |
|
|
246587802 |
Saurabh74 |
A |
Feb. 15, 2024, 7:52 p.m. |
OK |
GNU C11 |
TESTS |
3 |
15 |
0 |
|
|
246557122 |
enamulhoqmunna |
A |
Feb. 15, 2024, 4:18 p.m. |
OK |
GNU C11 |
TESTS |
3 |
15 |
0 |
|
|
246558978 |
Cmrit25_22R05A0427 |
A |
Feb. 15, 2024, 4:23 p.m. |
OK |
GNU C11 |
TESTS |
3 |
15 |
0 |
|
|
246562894 |
whaleeeee. |
A |
Feb. 15, 2024, 4:32 p.m. |
OK |
GNU C11 |
TESTS |
3 |
15 |
0 |
|
|
246584935 |
Saurabh74 |
A |
Feb. 15, 2024, 7:21 p.m. |
OK |
GNU C11 |
TESTS |
3 |
15 |
204800 |
|
|
246579241 |
priyansh0506 |
A |
Feb. 15, 2024, 6:27 p.m. |
OK |
GNU C11 |
TESTS |
3 |
15 |
204800 |
|
|
246588266 |
amustafali |
A |
Feb. 15, 2024, 7:57 p.m. |
OK |
GNU C11 |
TESTS |
3 |
15 |
307200 |
|
|
246587182 |
Saurabh74 |
A |
Feb. 15, 2024, 7:45 p.m. |
OK |
GNU C11 |
TESTS |
3 |
15 |
307200 |
|
|
246579233 |
Shreyas_Chougaonkar |
A |
Feb. 15, 2024, 6:27 p.m. |
OK |
GNU C11 |
TESTS |
3 |
15 |
307200 |
|
|
246584497 |
AHappyPotato |
A |
Feb. 15, 2024, 7:17 p.m. |
OK |
GNU C++17 |
TESTS |
3 |
0 |
0 |
|
|
246581836 |
al_Fares |
A |
Feb. 15, 2024, 6:51 p.m. |
OK |
GNU C++17 |
TESTS |
3 |
0 |
0 |
|
|
246581518 |
mmated |
A |
Feb. 15, 2024, 6:48 p.m. |
OK |
GNU C++17 |
TESTS |
3 |
0 |
0 |
|
|
246578722 |
MaDDy18 |
A |
Feb. 15, 2024, 6:23 p.m. |
OK |
GNU C++17 |
TESTS |
3 |
0 |
0 |
|
|
246575430 |
Dipto_801 |
A |
Feb. 15, 2024, 5:57 p.m. |
OK |
GNU C++17 |
TESTS |
3 |
0 |
0 |
|
|
246613053 |
StrangerbonD |
A |
Feb. 16, 2024, 3:48 a.m. |
OK |
GNU C++17 |
TESTS |
3 |
0 |
0 |
|
|
246617031 |
srikanthvupp |
A |
Feb. 16, 2024, 4:48 a.m. |
OK |
GNU C++17 |
TESTS |
3 |
0 |
0 |
|
|
246610644 |
ER3N_Yager |
A |
Feb. 16, 2024, 3:08 a.m. |
OK |
GNU C++17 |
TESTS |
3 |
0 |
0 |
|
|
246604206 |
SLPing |
A |
Feb. 16, 2024, 12:53 a.m. |
OK |
GNU C++17 |
TESTS |
3 |
0 |
0 |
|
|
246595967 |
vjcp |
A |
Feb. 15, 2024, 9:38 p.m. |
OK |
GNU C++17 |
TESTS |
3 |
0 |
0 |
|
|
246600172 |
s0fast |
A |
Feb. 15, 2024, 10:58 p.m. |
OK |
GNU C++17 (64) |
TESTS |
3 |
0 |
0 |
|
|
246605891 |
lonelywolf. |
A |
Feb. 16, 2024, 1:32 a.m. |
OK |
GNU C++17 (64) |
TESTS |
3 |
0 |
0 |
|
|
246606477 |
jackylova_fan_fan_fan |
A |
Feb. 16, 2024, 1:46 a.m. |
OK |
GNU C++17 (64) |
TESTS |
3 |
0 |
0 |
|
|
246571325 |
helloforces |
A |
Feb. 15, 2024, 5:26 p.m. |
OK |
GNU C++17 (64) |
TESTS |
3 |
0 |
0 |
|
|
246566919 |
ASTERIA_ |
A |
Feb. 15, 2024, 5:01 p.m. |
OK |
GNU C++17 (64) |
TESTS |
3 |
0 |
0 |
|
|
246561262 |
progskipper |
A |
Feb. 15, 2024, 4:29 p.m. |
OK |
GNU C++17 (64) |
TESTS |
3 |
0 |
0 |
|
|
246610941 |
aixia |
A |
Feb. 16, 2024, 3:13 a.m. |
OK |
GNU C++17 (64) |
TESTS |
3 |
0 |
0 |
|
|
246620673 |
fengjiuge |
A |
Feb. 16, 2024, 5:36 a.m. |
OK |
GNU C++17 (64) |
TESTS |
3 |
0 |
0 |
|
|
246568550 |
Chaos_Ljc |
A |
Feb. 15, 2024, 5:09 p.m. |
OK |
GNU C++17 (64) |
TESTS |
3 |
0 |
1638400 |
|
|
246608624 |
wzdxhxx |
A |
Feb. 16, 2024, 2:29 a.m. |
OK |
GNU C++17 (64) |
TESTS |
3 |
0 |
1638400 |
|
|
246616154 |
Mat_ADS |
A |
Feb. 16, 2024, 4:35 a.m. |
OK |
GNU C++20 (64) |
TESTS |
3 |
0 |
0 |
|
|
246616240 |
cpchenpi |
A |
Feb. 16, 2024, 4:36 a.m. |
OK |
GNU C++20 (64) |
TESTS |
3 |
0 |
0 |
|
|
246616623 |
azureglow |
A |
Feb. 16, 2024, 4:42 a.m. |
OK |
GNU C++20 (64) |
TESTS |
3 |
0 |
0 |
|
|
246616703 |
aryanjr2002203 |
A |
Feb. 16, 2024, 4:43 a.m. |
OK |
GNU C++20 (64) |
TESTS |
3 |
0 |
0 |
|
|
246616914 |
_Dhumketu_ |
A |
Feb. 16, 2024, 4:47 a.m. |
OK |
GNU C++20 (64) |
TESTS |
3 |
0 |
0 |
|
|
246616969 |
Mahbuba_Liza |
A |
Feb. 16, 2024, 4:47 a.m. |
OK |
GNU C++20 (64) |
TESTS |
3 |
0 |
0 |
|
|
246617926 |
Omar_Mahmoud_ |
A |
Feb. 16, 2024, 5 a.m. |
OK |
GNU C++20 (64) |
TESTS |
3 |
0 |
0 |
|
|
246620678 |
Yanyue |
A |
Feb. 16, 2024, 5:36 a.m. |
OK |
GNU C++20 (64) |
TESTS |
3 |
0 |
0 |
|
|
246621654 |
The_Boolean_Nerd |
A |
Feb. 16, 2024, 5:48 a.m. |
OK |
GNU C++20 (64) |
TESTS |
3 |
0 |
0 |
|
|
246622585 |
El-Metador |
A |
Feb. 16, 2024, 5:59 a.m. |
OK |
GNU C++20 (64) |
TESTS |
3 |
0 |
0 |
|
|
246601850 |
ArcaneA |
A |
Feb. 15, 2024, 11:42 p.m. |
OK |
Java 21 |
TESTS |
3 |
186 |
0 |
|
|
246574096 |
Nagendravarma |
A |
Feb. 15, 2024, 5:46 p.m. |
OK |
Java 21 |
TESTS |
3 |
217 |
0 |
|
|
246606350 |
Chewey |
A |
Feb. 16, 2024, 1:43 a.m. |
OK |
Java 21 |
TESTS |
3 |
218 |
0 |
|
|
246599551 |
Eren-Yeager |
A |
Feb. 15, 2024, 10:44 p.m. |
OK |
Java 21 |
TESTS |
3 |
218 |
0 |
|
|
246594458 |
Nekronishe |
A |
Feb. 15, 2024, 9:15 p.m. |
OK |
Java 21 |
TESTS |
3 |
218 |
0 |
|
|
246569073 |
minibin |
A |
Feb. 15, 2024, 5:12 p.m. |
OK |
Java 21 |
TESTS |
3 |
218 |
0 |
|
|
246570444 |
Dhruv_savani |
A |
Feb. 15, 2024, 5:21 p.m. |
OK |
Java 21 |
TESTS |
3 |
233 |
0 |
|
|
246568619 |
ramitg254 |
A |
Feb. 15, 2024, 5:10 p.m. |
OK |
Java 21 |
TESTS |
3 |
248 |
0 |
|
|
246567429 |
swatishivam23 |
A |
Feb. 15, 2024, 5:04 p.m. |
OK |
Java 21 |
TESTS |
3 |
248 |
0 |
|
|
246568635 |
black_rise |
A |
Feb. 15, 2024, 5:10 p.m. |
OK |
Java 21 |
TESTS |
3 |
264 |
0 |
|
|
246576069 |
yashvardhan3 |
A |
Feb. 15, 2024, 6:01 p.m. |
OK |
Java 8 |
TESTS |
3 |
93 |
0 |
|
|
246604288 |
tinku_vishnu |
A |
Feb. 16, 2024, 12:55 a.m. |
OK |
Java 8 |
TESTS |
3 |
108 |
0 |
|
|
246576786 |
Required |
A |
Feb. 15, 2024, 6:07 p.m. |
OK |
Java 8 |
TESTS |
3 |
108 |
0 |
|
|
246575944 |
rp9541439 |
A |
Feb. 15, 2024, 6:01 p.m. |
OK |
Java 8 |
TESTS |
3 |
139 |
0 |
|
|
246618158 |
1229050383ZS |
A |
Feb. 16, 2024, 5:04 a.m. |
OK |
Java 8 |
TESTS |
3 |
155 |
0 |
|
|
246603174 |
Steffi |
A |
Feb. 16, 2024, 12:23 a.m. |
OK |
Java 8 |
TESTS |
3 |
155 |
0 |
|
|
246611580 |
Mr_A |
A |
Feb. 16, 2024, 3:24 a.m. |
OK |
Java 8 |
TESTS |
3 |
171 |
0 |
|
|
246582755 |
parishithada |
A |
Feb. 15, 2024, 7 p.m. |
OK |
Java 8 |
TESTS |
3 |
171 |
0 |
|
|
246558400 |
vinod2122 |
A |
Feb. 15, 2024, 4:21 p.m. |
OK |
Java 8 |
TESTS |
3 |
171 |
0 |
|
|
246576431 |
berserk228 |
A |
Feb. 15, 2024, 6:04 p.m. |
OK |
Java 8 |
TESTS |
3 |
186 |
0 |
|
|
246592276 |
Gadi |
A |
Feb. 15, 2024, 8:45 p.m. |
OK |
MS C++ 2017 |
TESTS |
3 |
31 |
0 |
|
|
246558561 |
autumn_mountain |
A |
Feb. 15, 2024, 4:22 p.m. |
OK |
MS C++ 2017 |
TESTS |
3 |
31 |
0 |
|
|
246565887 |
FirstStep0 |
A |
Feb. 15, 2024, 4:57 p.m. |
OK |
MS C++ 2017 |
TESTS |
3 |
46 |
0 |
|
|
246561715 |
AD_cobra |
A |
Feb. 15, 2024, 4:30 p.m. |
OK |
MS C++ 2017 |
TESTS |
3 |
46 |
0 |
|
|
246559311 |
Egor1812 |
A |
Feb. 15, 2024, 4:24 p.m. |
OK |
MS C++ 2017 |
TESTS |
3 |
46 |
0 |
|
|
246620125 |
fww |
A |
Feb. 16, 2024, 5:28 a.m. |
OK |
MS C++ 2017 |
TESTS |
3 |
61 |
0 |
|
|
246619287 |
satyamkumar1345 |
A |
Feb. 16, 2024, 5:18 a.m. |
OK |
MS C++ 2017 |
TESTS |
3 |
62 |
0 |
|
|
246588993 |
6ziv |
A |
Feb. 15, 2024, 8:05 p.m. |
OK |
MS C++ 2017 |
TESTS |
3 |
62 |
0 |
|
|
246583649 |
nikhill28 |
A |
Feb. 15, 2024, 7:08 p.m. |
OK |
MS C++ 2017 |
TESTS |
3 |
62 |
0 |
|
|
246578059 |
zetiboom |
A |
Feb. 15, 2024, 6:17 p.m. |
OK |
MS C++ 2017 |
TESTS |
3 |
62 |
0 |
|
|
246594163 |
Oleg1999 |
A |
Feb. 15, 2024, 9:10 p.m. |
OK |
PascalABC.NET |
TESTS |
3 |
186 |
0 |
|
|
246601611 |
crapcode |
A |
Feb. 15, 2024, 11:35 p.m. |
OK |
PHP |
TESTS |
3 |
15 |
0 |
|
|
246576116 |
Kevin8502 |
A |
Feb. 15, 2024, 6:02 p.m. |
OK |
PHP |
TESTS |
3 |
46 |
0 |
|
|
246590990 |
lebron87 |
A |
Feb. 15, 2024, 8:28 p.m. |
OK |
PyPy 3 |
TESTS |
3 |
124 |
3379200 |
|
|
246606203 |
Cappucher |
A |
Feb. 16, 2024, 1:40 a.m. |
OK |
PyPy 3 |
TESTS |
3 |
155 |
3788800 |
|
|
246583607 |
nealzane |
A |
Feb. 15, 2024, 7:08 p.m. |
OK |
PyPy 3 |
TESTS |
3 |
202 |
5120000 |
|
|
246573044 |
xpoes |
A |
Feb. 15, 2024, 5:39 p.m. |
OK |
PyPy 3 |
TESTS |
3 |
202 |
6246400 |
|
|
246565724 |
InHng |
A |
Feb. 15, 2024, 4:57 p.m. |
OK |
PyPy 3-64 |
TESTS |
3 |
46 |
2252800 |
|
|
246584241 |
_Ryu__ |
A |
Feb. 15, 2024, 7:14 p.m. |
OK |
PyPy 3-64 |
TESTS |
3 |
62 |
2048000 |
|
|
246582073 |
abenezer_m54 |
A |
Feb. 15, 2024, 6:53 p.m. |
OK |
PyPy 3-64 |
TESTS |
3 |
62 |
2662400 |
|
|
246590804 |
gardengnome |
A |
Feb. 15, 2024, 8:26 p.m. |
OK |
PyPy 3-64 |
TESTS |
3 |
77 |
1945600 |
|
|
246621937 |
cybsbbb |
A |
Feb. 16, 2024, 5:51 a.m. |
OK |
PyPy 3-64 |
TESTS |
3 |
77 |
2560000 |
|
|
246608340 |
Drought |
A |
Feb. 16, 2024, 2:23 a.m. |
OK |
PyPy 3-64 |
TESTS |
3 |
77 |
2560000 |
|
|
246570102 |
AndreiZherder |
A |
Feb. 15, 2024, 5:19 p.m. |
OK |
PyPy 3-64 |
TESTS |
3 |
77 |
2560000 |
|
|
246590199 |
shadowcoder023 |
A |
Feb. 15, 2024, 8:19 p.m. |
OK |
PyPy 3-64 |
TESTS |
3 |
77 |
2969600 |
|
|
246581926 |
Pronoy_Deb |
A |
Feb. 15, 2024, 6:51 p.m. |
OK |
PyPy 3-64 |
TESTS |
3 |
77 |
3276800 |
|
|
246619727 |
PenguinSlayer_69 |
A |
Feb. 16, 2024, 5:23 a.m. |
OK |
PyPy 3-64 |
TESTS |
3 |
77 |
3379200 |
|
|
246566221 |
OLOGY |
A |
Feb. 15, 2024, 4:58 p.m. |
OK |
Python 2 |
TESTS |
3 |
46 |
1024000 |
|
|
246622739 |
Puspak-Sahu |
A |
Feb. 16, 2024, 6:01 a.m. |
OK |
Python 3 |
TESTS |
3 |
30 |
204800 |
|
|
246614841 |
devi_81374 |
A |
Feb. 16, 2024, 4:15 a.m. |
OK |
Python 3 |
TESTS |
3 |
30 |
204800 |
|
|
246579896 |
Jaideep19 |
A |
Feb. 15, 2024, 6:33 p.m. |
OK |
Python 3 |
TESTS |
3 |
30 |
614400 |
|
|
246582372 |
Volodya_Dudchak |
A |
Feb. 15, 2024, 6:56 p.m. |
OK |
Python 3 |
TESTS |
3 |
31 |
102400 |
|
|
246572912 |
Anonymous_HF |
A |
Feb. 15, 2024, 5:38 p.m. |
OK |
Python 3 |
TESTS |
3 |
31 |
102400 |
|
|
246558753 |
mohamedhosnimissaoui |
A |
Feb. 15, 2024, 4:22 p.m. |
OK |
Python 3 |
TESTS |
3 |
31 |
102400 |
|
|
246597034 |
thejadeassassin |
A |
Feb. 15, 2024, 9:53 p.m. |
OK |
Python 3 |
TESTS |
3 |
31 |
204800 |
|
|
246566619 |
Ivan_gribanov |
A |
Feb. 15, 2024, 5 p.m. |
OK |
Python 3 |
TESTS |
3 |
31 |
204800 |
|
|
246566220 |
Tejas_004 |
A |
Feb. 15, 2024, 4:58 p.m. |
OK |
Python 3 |
TESTS |
3 |
31 |
204800 |
|
|
246608332 |
wwgjy |
A |
Feb. 16, 2024, 2:23 a.m. |
OK |
Python 3 |
TESTS |
3 |
31 |
716800 |
|
|
246599400 |
ABOGBL |
A |
Feb. 15, 2024, 10:40 p.m. |
OK |
Ruby 3 |
TESTS |
3 |
389 |
409600 |
|
|
246580842 |
0x81 |
A |
Feb. 15, 2024, 6:41 p.m. |
OK |
Ruby 3 |
TESTS |
3 |
405 |
614400 |
|
|
246558556 |
sabbirahmeds877 |
A |
Feb. 15, 2024, 4:22 p.m. |
OK |
Ruby 3 |
TESTS |
3 |
483 |
307200 |
|
|
246568874 |
Chalaghoram |
A |
Feb. 15, 2024, 5:11 p.m. |
OK |
Rust 2021 |
TESTS |
3 |
15 |
0 |
|
|
246608748 |
BobChuckyJoe |
A |
Feb. 16, 2024, 2:32 a.m. |
OK |
Rust 2021 |
TESTS |
3 |
30 |
0 |
|
|
remove filters
Back to search problems