Codeforces Round 896 (Div. 1)

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
1868 Codeforces Round 896 (Div. 1) FINISHED False 9000 42825263 Sept. 10, 2023, 2:05 p.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 89 ) E Min-Sum-Max PROGRAMMING dp greedy

B'Tom is waiting for his results of Zhongkao examination. To ease the tense atmosphere, his friend, Daniel, decided to play a game with him. This game is called "Divide the Array". The game is about the array a consisting of n integers. Denote [l,r] as the subsegment consisting of integers a_l,a_{l+1}, ldots,a_r . Tom will divide the array into contiguous subsegments [l_1,r_1],[l_2,r_2], ldots,[l_m,r_m] , such that each integer is in exactly one subsegment. More formally: Denote s_{i}= sum_{k=l_i}^{r_i} a_k , that is, s_i is the sum of integers in the i -th subsegment. For all 1 <= i <= j <= m , the following condition must hold: min_{i <= k <= j} s_k <= sum_{k=i}^j s_k <= max_{i <= k <= j} s_k. Tom believes that the more subsegments the array a is divided into, the better results he will get. So he asks Daniel to find the maximum number of subsegments among all possible ways to divide the array a . You have to help him find it. The first line of input contains a single integer t ( 1 <= t <= 50 ) -- the number of test cases. The description of test cases follows. The first line of each test case contains a single integer n ( 1 <= n <= 300 ) -- the length of the array a . The second line of each test case contains n integers a_1,a_2, ldots,a_n ( -10^9 <= a_i <= 10^9 ) -- the elements of the array a . It is guaranteed that the sum of n over all test cases does not exceed 1000 . For each test case, output a single integer -- the maximum number of subsegments among all possible ways to divide the array a . In the first test case, Daniel can divide the array into [-1] and [5,4] , and s=[-1,9] . It can be shown that for any i=j , the condition in the statement is already satisfied, and for i=1,j=2 , we have min(-1,9) <= (-1)+9 <= max(-1,9) . In the second test case, if Daniel divides the a'...

Tutorials

Codeforces Round 896 (Div. 1, Div. 2) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
222843334 SoKee_USTC E Sept. 11, 2023, 1:58 a.m. OK GNU C++17 TESTS 78 1263 116019200
222837871 Kubic E Sept. 10, 2023, 11:49 p.m. OK GNU C++17 (64) TESTS 78 982 228966400
222807551 ksun48 E Sept. 10, 2023, 5:16 p.m. OK GNU C++20 (64) TESTS 78 1357 233984000
222833034 km_zakaria_alam E Sept. 10, 2023, 9:42 p.m. OK GNU C++20 (64) TESTS 78 1419 115609600
222784047 greenheadstrange E Sept. 10, 2023, 3:51 p.m. OK GNU C++20 (64) TESTS 78 1419 115609600
222815728 jiangly E Sept. 10, 2023, 6:12 p.m. OK GNU C++20 (64) TESTS 78 3540 684236800

remove filters

Back to search problems