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 an array a_1, a_2, ... , a_n , consisting of n integers. You are also given an integer value x . Let f(k) be the maximum sum of a contiguous subarray of a after applying the following operation: add x to the elements on exactly k distinct positions. An empty subarray should also be considered, it has sum 0 . Note that the subarray doesn't have to include all of the increased elements. Calculate the maximum value of f(k) for all k from 0 to n independently. The first line contains a single integer t ( 1 <= t <= 5000 ) -- the number of testcases. The first line of the testcase contains two integers n and x ( 1 <= n <= 5000 ; 0 <= x <= 10^5 ) -- the number of elements in the array and the value to add. The second line contains n integers a_1, a_2, ... , a_n ( -10^5 <= a_i <= 10^5 ). The sum of n over all testcases doesn't exceed 5000 . For each testcase, print n + 1 integers -- the maximum value of f(k) for all k from 0 to n independently. In the first testcase, it doesn't matter which elements you add x to. The subarray with the maximum sum will always be the entire array. If you increase k elements by x , k cdot x will be added to the sum. In the second testcase: "... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
147352490 |
allegrogiken |
C |
Feb. 22, 2022, 4:58 p.m. |
OK |
D |
TESTS |
6 |
31 |
4198400 |
|
|
147387910 |
kkjjyyoucan |
C |
Feb. 23, 2022, 4:31 a.m. |
OK |
GNU C++14 |
TESTS |
6 |
0 |
102400 |
|
|
147394575 |
zzzzym |
C |
Feb. 23, 2022, 6:03 a.m. |
OK |
GNU C++14 |
TESTS |
6 |
15 |
0 |
|
|
147384625 |
tythen |
C |
Feb. 23, 2022, 3:23 a.m. |
OK |
GNU C++14 |
TESTS |
6 |
15 |
0 |
|
|
147380913 |
2016gdgzoi467 |
C |
Feb. 23, 2022, 1:51 a.m. |
OK |
GNU C++14 |
TESTS |
6 |
15 |
102400 |
|
|
147380910 |
shangcheng |
C |
Feb. 23, 2022, 1:51 a.m. |
OK |
GNU C++14 |
TESTS |
6 |
15 |
102400 |
|
|
147379216 |
Free314 |
C |
Feb. 23, 2022, 12:59 a.m. |
OK |
GNU C++14 |
TESTS |
6 |
15 |
102400 |
|
|
147379553 |
moyujiang |
C |
Feb. 23, 2022, 1:10 a.m. |
OK |
GNU C++14 |
TESTS |
6 |
15 |
102400 |
|
|
147376888 |
retah |
C |
Feb. 22, 2022, 11:32 p.m. |
OK |
GNU C++14 |
TESTS |
6 |
15 |
102400 |
|
|
147384839 |
Vivek27951 |
C |
Feb. 23, 2022, 3:28 a.m. |
OK |
GNU C++14 |
TESTS |
6 |
15 |
102400 |
|
|
147383616 |
Scarlett_boy |
C |
Feb. 23, 2022, 3 a.m. |
OK |
GNU C++14 |
TESTS |
6 |
15 |
102400 |
|
|
147353083 |
JerryBlack |
C |
Feb. 22, 2022, 5:03 p.m. |
OK |
GNU C++17 |
TESTS |
6 |
0 |
102400 |
|
|
147369170 |
morancium |
C |
Feb. 22, 2022, 8:18 p.m. |
OK |
GNU C++17 |
TESTS |
6 |
15 |
0 |
|
|
147384077 |
ari_haran01 |
C |
Feb. 23, 2022, 3:10 a.m. |
OK |
GNU C++17 |
TESTS |
6 |
15 |
0 |
|
|
147388965 |
xiaobottle |
C |
Feb. 23, 2022, 4:48 a.m. |
OK |
GNU C++17 |
TESTS |
6 |
15 |
102400 |
|
|
147389528 |
jindal2003 |
C |
Feb. 23, 2022, 4:58 a.m. |
OK |
GNU C++17 |
TESTS |
6 |
15 |
102400 |
|
|
147388977 |
Exp_min |
C |
Feb. 23, 2022, 4:49 a.m. |
OK |
GNU C++17 |
TESTS |
6 |
15 |
102400 |
|
|
147393400 |
md_talim784 |
C |
Feb. 23, 2022, 5:49 a.m. |
OK |
GNU C++17 |
TESTS |
6 |
15 |
102400 |
|
|
147392373 |
kg151 |
C |
Feb. 23, 2022, 5:37 a.m. |
OK |
GNU C++17 |
TESTS |
6 |
15 |
102400 |
|
|
147390877 |
xjq |
C |
Feb. 23, 2022, 5:16 a.m. |
OK |
GNU C++17 |
TESTS |
6 |
15 |
102400 |
|
|
147390289 |
kaaaaa |
C |
Feb. 23, 2022, 5:09 a.m. |
OK |
GNU C++17 |
TESTS |
6 |
15 |
102400 |
|
|
147374555 |
archived_spark |
C |
Feb. 22, 2022, 10:13 p.m. |
OK |
GNU C++17 (64) |
TESTS |
6 |
0 |
102400 |
|
|
147385560 |
_priyanshu_ |
C |
Feb. 23, 2022, 3:45 a.m. |
OK |
GNU C++17 (64) |
TESTS |
6 |
0 |
204800 |
|
|
147393577 |
Dmi34 |
C |
Feb. 23, 2022, 5:51 a.m. |
OK |
GNU C++17 (64) |
TESTS |
6 |
15 |
0 |
|
|
147347396 |
JesCaim |
C |
Feb. 22, 2022, 4:32 p.m. |
OK |
GNU C++17 (64) |
TESTS |
6 |
15 |
0 |
|
|
147378369 |
froggyzhang |
C |
Feb. 23, 2022, 12:26 a.m. |
OK |
GNU C++17 (64) |
TESTS |
6 |
15 |
102400 |
|
|
147382785 |
froggyzhang |
C |
Feb. 23, 2022, 2:42 a.m. |
OK |
GNU C++17 (64) |
TESTS |
6 |
15 |
102400 |
|
|
147378504 |
LowLightK |
C |
Feb. 23, 2022, 12:31 a.m. |
OK |
GNU C++17 (64) |
TESTS |
6 |
15 |
102400 |
|
|
147388383 |
Haven_ |
C |
Feb. 23, 2022, 4:39 a.m. |
OK |
GNU C++17 (64) |
TESTS |
6 |
15 |
102400 |
|
|
147387774 |
moyujiang |
C |
Feb. 23, 2022, 4:29 a.m. |
OK |
GNU C++17 (64) |
TESTS |
6 |
15 |
102400 |
|
|
147385682 |
openmi |
C |
Feb. 23, 2022, 3:48 a.m. |
OK |
GNU C++17 (64) |
TESTS |
6 |
15 |
102400 |
|
|
147380743 |
the-other-sunny |
C |
Feb. 23, 2022, 1:45 a.m. |
OK |
GNU C++20 (64) |
TESTS |
6 |
0 |
0 |
|
|
147392666 |
daoxuantoan |
C |
Feb. 23, 2022, 5:40 a.m. |
OK |
GNU C++20 (64) |
TESTS |
6 |
0 |
102400 |
|
|
147348058 |
mdolchik |
C |
Feb. 22, 2022, 4:33 p.m. |
OK |
GNU C++20 (64) |
TESTS |
6 |
15 |
0 |
|
|
147359941 |
dush1729 |
C |
Feb. 22, 2022, 6:10 p.m. |
OK |
GNU C++20 (64) |
TESTS |
6 |
15 |
0 |
|
|
147359693 |
dush1729 |
C |
Feb. 22, 2022, 6:07 p.m. |
OK |
GNU C++20 (64) |
TESTS |
6 |
15 |
0 |
|
|
147388791 |
bitter. |
C |
Feb. 23, 2022, 4:46 a.m. |
OK |
GNU C++20 (64) |
TESTS |
6 |
15 |
0 |
|
|
147386786 |
foreverlasting |
C |
Feb. 23, 2022, 4:10 a.m. |
OK |
GNU C++20 (64) |
TESTS |
6 |
15 |
0 |
|
|
147386316 |
MohammadOmar |
C |
Feb. 23, 2022, 4:01 a.m. |
OK |
GNU C++20 (64) |
TESTS |
6 |
15 |
0 |
|
|
147390852 |
Naruto_cm |
C |
Feb. 23, 2022, 5:16 a.m. |
OK |
GNU C++20 (64) |
TESTS |
6 |
15 |
102400 |
|
|
147391556 |
ch1ihnuf8e |
C |
Feb. 23, 2022, 5:26 a.m. |
OK |
GNU C++20 (64) |
TESTS |
6 |
15 |
102400 |
|
|
147353835 |
clyring |
C |
Feb. 22, 2022, 5:09 p.m. |
OK |
Haskell |
TESTS |
6 |
46 |
0 |
|
|
147345507 |
clyring |
C |
Feb. 22, 2022, 4:28 p.m. |
OK |
Haskell |
TESTS |
6 |
61 |
0 |
|
|
147353399 |
thesupremeone |
C |
Feb. 22, 2022, 5:05 p.m. |
OK |
Java 11 |
TESTS |
6 |
171 |
0 |
|
|
147342700 |
Apocellipse |
C |
Feb. 22, 2022, 4:21 p.m. |
OK |
Java 11 |
TESTS |
6 |
186 |
0 |
|
|
147383722 |
Longgggggggg |
C |
Feb. 23, 2022, 3:03 a.m. |
OK |
Java 11 |
TESTS |
6 |
186 |
0 |
|
|
147342125 |
humwawe |
C |
Feb. 22, 2022, 4:19 p.m. |
OK |
Java 11 |
TESTS |
6 |
187 |
0 |
|
|
147353844 |
thesupremeone |
C |
Feb. 22, 2022, 5:09 p.m. |
OK |
Java 11 |
TESTS |
6 |
202 |
0 |
|
|
147342715 |
dzhi |
C |
Feb. 22, 2022, 4:21 p.m. |
OK |
Java 11 |
TESTS |
6 |
217 |
0 |
|
|
147365722 |
eshan18.09 |
C |
Feb. 22, 2022, 7:24 p.m. |
OK |
Java 11 |
TESTS |
6 |
217 |
0 |
|
|
147382095 |
kevinchangyupeng |
C |
Feb. 23, 2022, 2:24 a.m. |
OK |
Java 11 |
TESTS |
6 |
233 |
0 |
|
|
147343109 |
Isfandiyor |
C |
Feb. 22, 2022, 4:22 p.m. |
OK |
Java 11 |
TESTS |
6 |
233 |
0 |
|
|
147344918 |
T_Chakrawarty |
C |
Feb. 22, 2022, 4:26 p.m. |
OK |
Java 11 |
TESTS |
6 |
234 |
0 |
|
|
147364395 |
ss804 |
C |
Feb. 22, 2022, 7:05 p.m. |
OK |
Java 8 |
TESTS |
6 |
109 |
0 |
|
|
147375879 |
BogoSortIsBest |
C |
Feb. 22, 2022, 10:56 p.m. |
OK |
Java 8 |
TESTS |
6 |
109 |
0 |
|
|
147380307 |
Self7 |
C |
Feb. 23, 2022, 1:33 a.m. |
OK |
Java 8 |
TESTS |
6 |
124 |
0 |
|
|
147365287 |
amp_jn_231704 |
C |
Feb. 22, 2022, 7:18 p.m. |
OK |
Java 8 |
TESTS |
6 |
140 |
0 |
|
|
147374032 |
themadknight45 |
C |
Feb. 22, 2022, 10:01 p.m. |
OK |
Java 8 |
TESTS |
6 |
140 |
0 |
|
|
147365364 |
ninjamayank |
C |
Feb. 22, 2022, 7:19 p.m. |
OK |
Java 8 |
TESTS |
6 |
171 |
0 |
|
|
147354129 |
ninjamayank |
C |
Feb. 22, 2022, 5:12 p.m. |
OK |
Java 8 |
TESTS |
6 |
171 |
0 |
|
|
147346752 |
Nishant2312 |
C |
Feb. 22, 2022, 4:31 p.m. |
OK |
Java 8 |
TESTS |
6 |
202 |
0 |
|
|
147342425 |
Koka |
C |
Feb. 22, 2022, 4:20 p.m. |
OK |
Java 8 |
TESTS |
6 |
202 |
0 |
|
|
147389872 |
Swapniltri |
C |
Feb. 23, 2022, 5:03 a.m. |
OK |
Java 8 |
TESTS |
6 |
234 |
0 |
|
|
147351430 |
arvindf232 |
C |
Feb. 22, 2022, 4:50 p.m. |
OK |
Kotlin 1.4 |
TESTS |
6 |
1388 |
0 |
|
|
147351549 |
BruteForcee |
C |
Feb. 22, 2022, 4:51 p.m. |
OK |
Kotlin 1.5 |
TESTS |
6 |
233 |
0 |
|
|
147362284 |
Potassium |
C |
Feb. 22, 2022, 6:37 p.m. |
OK |
Kotlin 1.5 |
TESTS |
6 |
779 |
0 |
|
|
147352601 |
hcp |
C |
Feb. 22, 2022, 4:59 p.m. |
OK |
MS C++ 2017 |
TESTS |
6 |
31 |
102400 |
|
|
147351089 |
SinaLIze |
C |
Feb. 22, 2022, 4:48 p.m. |
OK |
MS C++ 2017 |
TESTS |
6 |
31 |
102400 |
|
|
147369787 |
nikuradze2006 |
C |
Feb. 22, 2022, 8:29 p.m. |
OK |
MS C++ 2017 |
TESTS |
6 |
46 |
0 |
|
|
147345226 |
meowstar |
C |
Feb. 22, 2022, 4:27 p.m. |
OK |
MS C++ 2017 |
TESTS |
6 |
62 |
102400 |
|
|
147342120 |
Schullz |
C |
Feb. 22, 2022, 4:19 p.m. |
OK |
MS C++ 2017 |
TESTS |
6 |
78 |
102400 |
|
|
147343196 |
A_Pier |
C |
Feb. 22, 2022, 4:22 p.m. |
OK |
MS C++ 2017 |
TESTS |
6 |
109 |
204800 |
|
|
147353730 |
M7md3sam070 |
C |
Feb. 22, 2022, 5:08 p.m. |
OK |
MS C++ 2017 |
TESTS |
6 |
124 |
102400 |
|
|
147381803 |
Killer_No.47 |
C |
Feb. 23, 2022, 2:16 a.m. |
OK |
MS C++ 2017 |
TESTS |
6 |
155 |
102092800 |
|
|
147342685 |
fatant |
C |
Feb. 22, 2022, 4:21 p.m. |
OK |
MS C++ 2017 |
TESTS |
6 |
249 |
201113600 |
|
|
147367527 |
suraj |
C |
Feb. 22, 2022, 7:51 p.m. |
OK |
.NET Core C# |
TESTS |
6 |
139 |
3174400 |
|
|
147343922 |
reosfire |
C |
Feb. 22, 2022, 4:24 p.m. |
OK |
.NET Core C# |
TESTS |
6 |
420 |
3481600 |
|
|
147368238 |
rsFalse |
C |
Feb. 22, 2022, 8:02 p.m. |
OK |
Perl |
TESTS |
6 |
1544 |
1638400 |
|
|
147362549 |
rsFalse |
C |
Feb. 22, 2022, 6:40 p.m. |
OK |
Perl |
TESTS |
6 |
1544 |
1740800 |
|
|
147360941 |
rsFalse |
C |
Feb. 22, 2022, 6:21 p.m. |
OK |
Perl |
TESTS |
6 |
1637 |
1331200 |
|
|
147360302 |
rsFalse |
C |
Feb. 22, 2022, 6:14 p.m. |
OK |
Perl |
TESTS |
6 |
1638 |
1331200 |
|
|
147354417 |
OLOGY |
C |
Feb. 22, 2022, 5:14 p.m. |
OK |
PyPy 2 |
TESTS |
6 |
202 |
4198400 |
|
|
147355325 |
OLOGY |
C |
Feb. 22, 2022, 5:22 p.m. |
OK |
PyPy 2 |
TESTS |
6 |
358 |
3379200 |
|
|
147366466 |
MistaAsh |
C |
Feb. 22, 2022, 7:34 p.m. |
OK |
PyPy 3 |
TESTS |
6 |
155 |
4915200 |
|
|
147350935 |
AgentNinja |
C |
Feb. 22, 2022, 4:47 p.m. |
OK |
PyPy 3 |
TESTS |
6 |
202 |
5836800 |
|
|
147378583 |
Ahmed_Turkman |
C |
Feb. 23, 2022, 12:34 a.m. |
OK |
PyPy 3 |
TESTS |
6 |
217 |
5836800 |
|
|
147375463 |
unknownSolver |
C |
Feb. 22, 2022, 10:42 p.m. |
OK |
PyPy 3 |
TESTS |
6 |
218 |
6963200 |
|
|
147352639 |
Abdalkhalig |
C |
Feb. 22, 2022, 4:59 p.m. |
OK |
PyPy 3 |
TESTS |
6 |
233 |
9523200 |
|
|
147381988 |
shehebe |
C |
Feb. 23, 2022, 2:22 a.m. |
OK |
PyPy 3 |
TESTS |
6 |
234 |
5939200 |
|
|
147357419 |
majay1638 |
C |
Feb. 22, 2022, 5:42 p.m. |
OK |
PyPy 3 |
TESTS |
6 |
248 |
8601600 |
|
|
147371669 |
_nathan_drake_ |
C |
Feb. 22, 2022, 9:04 p.m. |
OK |
PyPy 3 |
TESTS |
6 |
249 |
10035200 |
|
|
147354199 |
Dhruv_Viradiya |
C |
Feb. 22, 2022, 5:12 p.m. |
OK |
PyPy 3 |
TESTS |
6 |
295 |
9113600 |
|
|
147378978 |
divyamkakkar24 |
C |
Feb. 23, 2022, 12:50 a.m. |
OK |
PyPy 3 |
TESTS |
6 |
311 |
6041600 |
|
|
147365193 |
oadey89 |
C |
Feb. 22, 2022, 7:17 p.m. |
OK |
PyPy 3-64 |
TESTS |
6 |
155 |
11264000 |
|
|
147391801 |
p_r_a_n_a_v |
C |
Feb. 23, 2022, 5:29 a.m. |
OK |
PyPy 3-64 |
TESTS |
6 |
171 |
12288000 |
|
|
147373133 |
MrVroom999 |
C |
Feb. 22, 2022, 9:38 p.m. |
OK |
PyPy 3-64 |
TESTS |
6 |
186 |
8601600 |
|
|
147349689 |
Rajveer_100 |
C |
Feb. 22, 2022, 4:40 p.m. |
OK |
PyPy 3-64 |
TESTS |
6 |
202 |
6553600 |
|
|
147350640 |
aman404found |
C |
Feb. 22, 2022, 4:45 p.m. |
OK |
PyPy 3-64 |
TESTS |
6 |
202 |
7680000 |
|
|
147371772 |
_nathan_drake_ |
C |
Feb. 22, 2022, 9:06 p.m. |
OK |
PyPy 3-64 |
TESTS |
6 |
202 |
10444800 |
|
|
147371726 |
_nathan_drake_ |
C |
Feb. 22, 2022, 9:05 p.m. |
OK |
PyPy 3-64 |
TESTS |
6 |
202 |
10547200 |
|
|
147346966 |
Anti-Neutrino |
C |
Feb. 22, 2022, 4:31 p.m. |
OK |
PyPy 3-64 |
TESTS |
6 |
217 |
5632000 |
|
|
147350717 |
Dixit_here |
C |
Feb. 22, 2022, 4:46 p.m. |
OK |
PyPy 3-64 |
TESTS |
6 |
249 |
8704000 |
|
|
147377225 |
MrVroom999 |
C |
Feb. 22, 2022, 11:45 p.m. |
OK |
PyPy 3-64 |
TESTS |
6 |
249 |
10137600 |
|
|
147347213 |
Garouka |
C |
Feb. 22, 2022, 4:32 p.m. |
OK |
Rust 2021 |
TESTS |
6 |
31 |
102400 |
|
|
147390806 |
bqn |
C |
Feb. 23, 2022, 5:15 a.m. |
OK |
Rust 2021 |
TESTS |
6 |
31 |
512000 |
|
|
remove filters
Back to search problems