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"You are given two integer arrays a and b , both of length n . You can perform the following operation any number of times (possibly zero): swap a_i and b_i . Let f(c) be the maximum sum of a contiguous subarray of the array c (including the empty subsegment, which sum is 0 ). Your task is to calculate the maximum possible value of f(a) + f(b) , using the aforementioned operation any number of times. The first line contains a single integer t ( 1 <= t <= 10^4 ) -- the number of test cases. The first line of each test case contains a single integer n ( 1 <= n <= 2 cdot 10^5 ). The second line contains n integers a_1, a_2, ... , a_n ( -10^9 <= a_i <= 10^9 ). The third line contains n integers b_1, b_2, ... , b_n ( -10^9 <= b_i <= 10^9 ). The sum of n over all test case doesn't exceed 2 cdot 10^5 . For each test case, print a single integer -- the maximum possible value of f(a) + f(b) , using the aforementioned operation any number of times. "... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
236800332 |
happy.potato |
E |
Dec. 11, 2023, 3:28 p.m. |
OK |
Kotlin 1.7 |
TESTS |
24 |
374 |
28569600 |
|
|
236812289 |
cftauros |
E |
Dec. 11, 2023, 4:54 p.m. |
OK |
Kotlin 1.7 |
TESTS |
24 |
420 |
39936000 |
|
|
236795697 |
arvindf232 |
E |
Dec. 11, 2023, 3:01 p.m. |
OK |
Kotlin 1.7 |
TESTS |
24 |
498 |
11468800 |
|
|
236805488 |
Hakiobo |
E |
Dec. 11, 2023, 4:03 p.m. |
OK |
Kotlin 1.7 |
TESTS |
24 |
545 |
43110400 |
|
|
236805084 |
DeadlyDuo |
E |
Dec. 11, 2023, 3:59 p.m. |
OK |
Kotlin 1.7 |
TESTS |
24 |
670 |
79564800 |
|
|
236797197 |
pashka |
E |
Dec. 11, 2023, 3:09 p.m. |
OK |
Kotlin 1.7 |
TESTS |
24 |
732 |
137932800 |
|
|
236806713 |
MagentaCobra |
E |
Dec. 11, 2023, 4:11 p.m. |
OK |
Kotlin 1.7 |
TESTS |
24 |
748 |
98816000 |
|
|
236810766 |
Fortin |
E |
Dec. 11, 2023, 4:43 p.m. |
OK |
Kotlin 1.7 |
TESTS |
24 |
795 |
144896000 |
|
|
236834570 |
Sumitsingh7 |
E |
Dec. 11, 2023, 9 p.m. |
OK |
Kotlin 1.7 |
TESTS |
24 |
826 |
128409600 |
|
|
236806096 |
BucketPotato |
E |
Dec. 11, 2023, 4:07 p.m. |
OK |
Kotlin 1.7 |
TESTS |
24 |
826 |
140185600 |
|
|
236802600 |
thenymphsofdelphi |
E |
Dec. 11, 2023, 3:43 p.m. |
OK |
Kotlin 1.9 |
TESTS |
24 |
592 |
153395200 |
|
|
236804404 |
crimsonred |
E |
Dec. 11, 2023, 3:55 p.m. |
OK |
Kotlin 1.9 |
TESTS |
24 |
623 |
81612800 |
|
|
236835890 |
mcrash12 |
E |
Dec. 11, 2023, 9:23 p.m. |
OK |
Kotlin 1.9 |
TESTS |
24 |
670 |
87040000 |
|
|
236804085 |
nuip |
E |
Dec. 11, 2023, 3:53 p.m. |
OK |
Kotlin 1.9 |
TESTS |
24 |
701 |
136192000 |
|
|
236804994 |
dyukha |
E |
Dec. 11, 2023, 3:59 p.m. |
OK |
Kotlin 1.9 |
TESTS |
24 |
748 |
140902400 |
|
|
236824920 |
cs142857 |
E |
Dec. 11, 2023, 6:51 p.m. |
OK |
Kotlin 1.9 |
TESTS |
24 |
764 |
109465600 |
|
|
236800107 |
lightseba |
E |
Dec. 11, 2023, 3:26 p.m. |
OK |
Kotlin 1.9 |
TESTS |
24 |
811 |
79564800 |
|
|
236803904 |
why_needed |
E |
Dec. 11, 2023, 3:51 p.m. |
OK |
Kotlin 1.9 |
TESTS |
24 |
857 |
138240000 |
|
|
236811406 |
jtrh |
E |
Dec. 11, 2023, 4:48 p.m. |
OK |
Kotlin 1.9 |
TESTS |
24 |
888 |
137523200 |
|
|
236851009 |
Lonen |
E |
Dec. 12, 2023, 4:03 a.m. |
OK |
Kotlin 1.9 |
TESTS |
24 |
888 |
138035200 |
|
|
remove filters
Back to search problems