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 array a_1, a_2, ... , a_n . You need to split it into k subsegments (so every element is included in exactly one subsegment). The weight of a subsegment a_l, a_{l+1}, ... , a_r is equal to (r - l + 1) cdot max limits_{l <= i <= r}(a_i) . The weight of a partition is a total weight of all its segments. Find the partition of minimal weight. The first line contains two integers n and k ( 1 <= n <= 2 cdot 10^4 , 1 <= k <= min(100, n) ) -- the length of the array a and the number of subsegments in the partition. The second line contains n integers a_1, a_2, ... , a_n ( 1 <= a_i <= 2 cdot 10^4 ) -- the array a . Print single integer -- the minimal weight among all possible partitions. The optimal partition in the first example is next: 6 1 7 bigg| 4 . The optimal partition in the second example is next: 6 bigg| 1 bigg| 7 4 . One of the optimal partitions in the third example is next: 5 bigg| 1 5 bigg| 1 bigg| 5 . '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
60150539 |
TrivialMan |
G |
Sept. 6, 2019, 3:41 a.m. |
OK |
GNU C++11 |
TESTS |
81 |
374 |
614400 |
|
2700 |
57865684 |
lopare |
G |
July 27, 2019, 8:50 p.m. |
OK |
GNU C++11 |
TESTS |
81 |
390 |
409600 |
|
2700 |
57709927 |
py_ultron |
G |
July 24, 2019, 10:56 p.m. |
OK |
GNU C++11 |
TESTS |
81 |
390 |
409600 |
|
2700 |
55519450 |
frodakcin |
G |
June 13, 2019, 7:37 a.m. |
OK |
GNU C++11 |
TESTS |
81 |
390 |
512000 |
|
2700 |
55399331 |
Gaozijian |
G |
June 10, 2019, 1:18 p.m. |
OK |
GNU C++11 |
TESTS |
81 |
390 |
512000 |
|
2700 |
55610721 |
ReaLNero1 |
G |
June 16, 2019, 5:32 a.m. |
OK |
GNU C++11 |
TESTS |
81 |
390 |
614400 |
|
2700 |
55208650 |
Winniechen |
G |
June 6, 2019, 1:40 p.m. |
OK |
GNU C++11 |
TESTS |
81 |
390 |
614400 |
|
2700 |
55384210 |
maxtir |
G |
June 10, 2019, 12:58 a.m. |
OK |
GNU C++11 |
TESTS |
81 |
405 |
614400 |
|
2700 |
55239397 |
lintoto |
G |
June 7, 2019, 10:05 a.m. |
OK |
GNU C++11 |
TESTS |
81 |
405 |
614400 |
|
2700 |
55399429 |
Cong1500DanPaiXia0 |
G |
June 10, 2019, 1:21 p.m. |
OK |
GNU C++11 |
TESTS |
81 |
468 |
9216000 |
|
2700 |
55186467 |
Maripium |
G |
June 6, 2019, 3:45 a.m. |
OK |
GNU C++14 |
TESTS |
81 |
373 |
614400 |
|
2700 |
56716384 |
faculty |
G |
July 8, 2019, 2:49 p.m. |
OK |
GNU C++14 |
TESTS |
81 |
420 |
512000 |
|
2700 |
55298533 |
cloudsky01 |
G |
June 8, 2019, 10:56 a.m. |
OK |
GNU C++14 |
TESTS |
81 |
421 |
512000 |
|
2700 |
56883535 |
faculty |
G |
July 12, 2019, 11:33 a.m. |
OK |
GNU C++14 |
TESTS |
81 |
436 |
512000 |
|
2700 |
55513153 |
sonhv3112 |
G |
June 13, 2019, 2:21 a.m. |
OK |
GNU C++14 |
TESTS |
81 |
436 |
716800 |
|
2700 |
55293422 |
mobu233 |
G |
June 8, 2019, 8:47 a.m. |
OK |
GNU C++14 |
TESTS |
81 |
452 |
1638400 |
|
2700 |
56883571 |
faculty |
G |
July 12, 2019, 11:34 a.m. |
OK |
GNU C++14 |
TESTS |
81 |
467 |
512000 |
|
2700 |
55282369 |
tmwilliamlin168 |
G |
June 8, 2019, 2:16 a.m. |
OK |
GNU C++14 |
TESTS |
81 |
514 |
512000 |
|
2700 |
55428731 |
beginend |
G |
June 11, 2019, 10:16 a.m. |
OK |
GNU C++14 |
TESTS |
81 |
607 |
8908800 |
|
2700 |
56946970 |
faculty |
G |
July 12, 2019, 11:11 p.m. |
OK |
GNU C++14 |
TESTS |
81 |
826 |
1024000 |
|
2700 |
58487802 |
neal |
G |
Aug. 9, 2019, 8:22 a.m. |
OK |
GNU C++17 |
TESTS |
81 |
405 |
1126400 |
|
2700 |
58463839 |
neal |
G |
Aug. 8, 2019, 6:09 p.m. |
OK |
GNU C++17 |
TESTS |
81 |
405 |
1126400 |
|
2700 |
56391261 |
Shayan.P |
G |
July 1, 2019, 12:41 p.m. |
OK |
GNU C++17 |
TESTS |
81 |
608 |
14848000 |
|
2700 |
58464860 |
neal |
G |
Aug. 8, 2019, 6:46 p.m. |
OK |
GNU C++17 |
TESTS |
81 |
685 |
1126400 |
|
2700 |
55474266 |
pbt17 |
G |
June 11, 2019, 9:14 p.m. |
OK |
GNU C++17 |
TESTS |
81 |
732 |
1228800 |
|
2700 |
57887729 |
capsule |
G |
July 28, 2019, 10:38 a.m. |
OK |
GNU C++17 |
TESTS |
81 |
1091 |
1126400 |
|
2700 |
55232850 |
hyfzbtrs |
G |
June 7, 2019, 6:43 a.m. |
OK |
GNU C++17 |
TESTS |
81 |
1232 |
1126400 |
|
2700 |
55189467 |
ei133333 |
G |
June 6, 2019, 5:47 a.m. |
OK |
GNU C++17 |
TESTS |
81 |
1248 |
8806400 |
|
2700 |
58463676 |
neal |
G |
Aug. 8, 2019, 6:03 p.m. |
OK |
GNU C++17 |
TESTS |
81 |
1387 |
2150400 |
|
2700 |
55280839 |
Benq |
G |
June 8, 2019, 12:41 a.m. |
OK |
GNU C++17 |
TESTS |
81 |
1419 |
716800 |
|
2700 |
55239071 |
uwi |
G |
June 7, 2019, 9:53 a.m. |
OK |
Java 8 |
TESTS |
81 |
2823 |
20992000 |
|
2700 |
remove filters
Back to search problems