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
Pak Chanek has a friend who runs a drink stall in a canteen. His friend will sell drinks for (n) days, numbered from day (1) to day (n). There are also (m) types of drinks, numbered from (1) to (m). The profit gained from selling a drink on a particular day can vary. On day (i), the projected profit from selling drink of type (j) is (A_{i, j}). Note that (A_{i, j}) can be negative, meaning that selling the drink would actually incur a loss. Pak Chanek wants to help his friend plan the sales over the (n) days. On day (i), Pak Chanek must choose to sell at least one type of drink. Furthermore, the types of drinks sold on a single day must form a subarray. In other words, in each day, Pak Chanek will select (i) and (j) such that (1 \leq i \leq j \leq m). Then all types of drinks between (i) and (j) (inclusive) will be sold. However, to ensure that customers from the previous day keep returning, the selection of drink types sold on day (i) ((i>1)) must meet the following conditions: At least one drink type sold on day (i) must also have been sold on day (i-1). At least one drink type sold on day (i) must not have been sold on day (i-1). The daily profit is the sum of the profits from all drink types sold on that day. The total profit from the sales plan is the sum of the profits over (n) days. What is the maximum total profit that can be achieved if Pak Chanek plans the sales optimally? Each test contains multiple test cases. The first line contains the number of test cases (t) ((1 \le t \le 1000)). The description of the test cases follows. The first line of each test case contains two integers (n) and (m) ((1 \leq n \leq 2 \cdot 10^5); (3 \leq m \leq 2 \cdot 10^5); (n \cdot m \leq 2 \cdot 10^5)) — the number of rows and columns in a grid. The next (n) lines of each test case contain (m) integers each, where the (i)-th line c |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|
284673557 |
liympanda |
D |
Oct. 6, 2024, 4:25 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
53 |
109 |
9216000 |
|
|
|
284635894 |
21eg107a24 |
D |
Oct. 6, 2024, noon |
OK |
C++17 (GCC 7-32) |
TESTS |
53 |
124 |
6451200 |
|
|
|
284630423 |
Chenly |
D |
Oct. 6, 2024, 11:27 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
53 |
124 |
8089600 |
|
|
|
284632616 |
neonaht |
D |
Oct. 6, 2024, 11:40 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
53 |
124 |
11264000 |
|
|
|
284644235 |
yuanhaowei |
D |
Oct. 6, 2024, 12:55 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
53 |
125 |
13721600 |
|
|
|
284643274 |
yaoyanfeng |
D |
Oct. 6, 2024, 12:48 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
53 |
140 |
6451200 |
|
|
|
284708578 |
lizeyu2008 |
D |
Oct. 7, 2024, 12:42 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
53 |
140 |
12902400 |
|
|
|
284663502 |
lenhanboofficial |
D |
Oct. 6, 2024, 3:04 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
53 |
140 |
24985600 |
|
|
|
284714562 |
emulative |
D |
Oct. 7, 2024, 3:03 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
53 |
155 |
14336000 |
|
|
|
284676550 |
lingehhhc |
D |
Oct. 6, 2024, 4:51 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
53 |
155 |
50892800 |
|
|
|
284666966 |
gaga999 |
D |
Oct. 6, 2024, 3:31 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
53 |
77 |
8192000 |
|
|
|
284725343 |
zacharychao |
D |
Oct. 7, 2024, 5:38 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
53 |
93 |
4403200 |
|
|
|
284701604 |
Ormlis |
D |
Oct. 6, 2024, 9:13 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
53 |
93 |
5017600 |
|
|
|
284671904 |
wishgoodluck |
D |
Oct. 6, 2024, 4:10 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
53 |
93 |
5939200 |
|
|
|
284662225 |
zjdl |
D |
Oct. 6, 2024, 2:55 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
53 |
93 |
6041600 |
|
|
|
284669022 |
zas111lll |
D |
Oct. 6, 2024, 3:47 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
53 |
93 |
7577600 |
|
|
|
284673905 |
ji_114514 |
D |
Oct. 6, 2024, 4:28 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
53 |
93 |
8089600 |
|
|
|
284700084 |
JinnyW |
D |
Oct. 6, 2024, 8:53 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
53 |
93 |
11468800 |
|
|
|
284653957 |
hopeWorse |
D |
Oct. 6, 2024, 1:59 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
53 |
93 |
12390400 |
|
|
|
284673345 |
Wael_Zaiback |
D |
Oct. 6, 2024, 4:24 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
53 |
108 |
4300800 |
|
|
|
284607478 |
ecnerwala |
D |
Oct. 6, 2024, 9:07 a.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
52 |
108 |
4812800 |
|
|
|
284714886 |
hhhyh |
D |
Oct. 7, 2024, 3:09 a.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
53 |
108 |
7372800 |
|
|
|
284606134 |
ecnerwala |
D |
Oct. 6, 2024, 8:59 a.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
52 |
109 |
102400 |
|
|
|
284607088 |
ecnerwala |
D |
Oct. 6, 2024, 9:04 a.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
52 |
109 |
1228800 |
|
|
|
284693085 |
244mhq |
D |
Oct. 6, 2024, 7:22 p.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
53 |
109 |
2662400 |
|
|
|
284656697 |
V.chandini_sri |
D |
Oct. 6, 2024, 2:17 p.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
53 |
109 |
4096000 |
|
|
|
284694960 |
DrSwad |
D |
Oct. 6, 2024, 7:42 p.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
53 |
109 |
5632000 |
|
|
|
284614235 |
415411 |
D |
Oct. 6, 2024, 9:47 a.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
52 |
109 |
8089600 |
|
|
|
284608659 |
nuyoah007 |
D |
Oct. 6, 2024, 9:14 a.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
52 |
109 |
10854400 |
|
|
|
284645835 |
Dominater069 |
D |
Oct. 6, 2024, 1:05 p.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
53 |
124 |
2662400 |
|
|
|
284666027 |
new2ac |
D |
Oct. 6, 2024, 3:23 p.m. |
OK |
Java 21 |
TESTS |
53 |
405 |
10649600 |
|
|
|
284610982 |
IOI1947 |
D |
Oct. 6, 2024, 9:29 a.m. |
OK |
Java 8 |
TESTS |
52 |
233 |
22630400 |
|
|
|
284690760 |
yvbf |
D |
Oct. 6, 2024, 6:58 p.m. |
OK |
Java 8 |
TESTS |
53 |
296 |
18329600 |
|
|
|
284654229 |
bnmanubharadwaj |
D |
Oct. 6, 2024, 2 p.m. |
OK |
Node.js |
TESTS |
53 |
374 |
90624000 |
|
|
|
284686858 |
gardengnome |
D |
Oct. 6, 2024, 6:21 p.m. |
OK |
PyPy 3-64 |
TESTS |
53 |
218 |
26726400 |
|
|
|
284688613 |
gardengnome |
D |
Oct. 6, 2024, 6:37 p.m. |
OK |
PyPy 3-64 |
TESTS |
53 |
234 |
26726400 |
|
|
|
284715320 |
Little_Sheep_Yawn |
D |
Oct. 7, 2024, 3:18 a.m. |
OK |
PyPy 3-64 |
TESTS |
53 |
296 |
32256000 |
|
|
|
284617828 |
LMeyling |
D |
Oct. 6, 2024, 10:09 a.m. |
OK |
PyPy 3-64 |
TESTS |
52 |
327 |
28057600 |
|
|
remove filters
Back to search problems