Good Bye 2025

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.

ContestId
Name
Phase
Frozen
Duration (Seconds)
Relative Time
Start Time
2178 Good Bye 2025 FINISHED False 10800 9559523 Dec. 27, 2025, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 15540 ) C First or Second PROGRAMMING dp greedy implementation

There are (n) children standing in a line, where the niceness of the (i)-th child is (a_i). Santa is deciding which children belong on the nice list and which belong on the naughty list. An integer (X) is initially set to (0). Santa will perform the following operation exactly (n-1) times: Choose the first or second child in line and remove them from the line. Let (w) be the niceness of the chosen child. If the first child was chosen, add them to the nice list and add (w) to (X). If the second child was chosen, add them to the naughty list and subtract (w) from (X). If the first child was chosen, add them to the nice list and add (w) to (X). If the second child was chosen, add them to the naughty list and subtract (w) from (X). Note that after all operations, exactly one child remains unassigned to a list. Determine the maximum possible value of (X) that Santa can obtain after all (n-1) operations. Each test contains multiple test cases. The first line contains the number of test cases (t) ((1 \le t \le 10^4)). The description of the test cases follows. The first line of each test case contains a single integer (n) ((2\le n\le 2\cdot 10^5)) — the number of children. The second line contains (n) integers (a_1,a_2,\ldots,a_n) ((-10^9\le a_i\le 10^9)) — the niceness of each child. It is guaranteed that the sum of (n) over all test cases does not exceed (2\cdot 10 ^ 5). For each test case, print a single integer — the maximum possible value of (X) that Santa can obtain after all (n-1) operations. In the first test case, Santa will perform exactly one operation. If he chooses the first child, he will add (a_1=2) to (X) to get (X=2); if he chooses the second child, he will subtract (a_2=-3) from (X) to get (X=3). Thus, the answer is (3). In the second test case, it is optimal to select the first child in all three operations

Tutorials

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
355444036 ya_hossein C Dec. 28, 2025, 5:40 a.m. OK C# 13 TESTS 15 93 42803200
355440822 deefpried C Dec. 28, 2025, 4:55 a.m. OK C++17 (GCC 7-32) TESTS 15 62 819200
355436135 whitewolf C Dec. 28, 2025, 3:32 a.m. OK C++17 (GCC 7-32) TESTS 15 62 921600
355444088 rishit3234 C Dec. 28, 2025, 5:41 a.m. OK C++17 (GCC 7-32) TESTS 15 78 0
355442540 BeSerious C Dec. 28, 2025, 5:21 a.m. OK C++17 (GCC 7-32) TESTS 15 78 0
355440138 pranabmishra2602 C Dec. 28, 2025, 4:44 a.m. OK C++17 (GCC 7-32) TESTS 15 78 0
355437769 ayukumar242004 C Dec. 28, 2025, 4:02 a.m. OK C++17 (GCC 7-32) TESTS 15 78 0
355437204 momo_chutney C Dec. 28, 2025, 3:51 a.m. OK C++17 (GCC 7-32) TESTS 15 78 0
355434463 rishabhyadav4446 C Dec. 28, 2025, 3 a.m. OK C++17 (GCC 7-32) TESTS 15 78 0
355432406 Jim_X C Dec. 28, 2025, 2:12 a.m. OK C++17 (GCC 7-32) TESTS 15 78 0
355430166 syam_adam C Dec. 28, 2025, 1:17 a.m. OK C++17 (GCC 7-32) TESTS 15 78 0
355446718 n00bmaster__ C Dec. 28, 2025, 6:10 a.m. OK C++20 (GCC 13-64) TESTS 15 62 0
355441918 niter C Dec. 28, 2025, 5:12 a.m. OK C++20 (GCC 13-64) TESTS 15 62 0
355440672 yendelevium C Dec. 28, 2025, 4:53 a.m. OK C++20 (GCC 13-64) TESTS 15 62 0
355438490 psuedocoder C Dec. 28, 2025, 4:15 a.m. OK C++20 (GCC 13-64) TESTS 15 62 0
355438256 Jteh C Dec. 28, 2025, 4:11 a.m. OK C++20 (GCC 13-64) TESTS 15 62 0
355430755 F_Hasan C Dec. 28, 2025, 1:32 a.m. OK C++20 (GCC 13-64) TESTS 15 62 0
355429519 KayserX C Dec. 28, 2025, 1:01 a.m. OK C++20 (GCC 13-64) TESTS 15 62 0
355428447 Noborita C Dec. 28, 2025, 12:27 a.m. OK C++20 (GCC 13-64) TESTS 15 62 0
355427125 gvihvo C Dec. 27, 2025, 11:36 p.m. OK C++20 (GCC 13-64) TESTS 15 62 0
355418237 jakub.zip C Dec. 27, 2025, 8:27 p.m. OK C++20 (GCC 13-64) TESTS 15 62 0

remove filters

Back to search problems