{"problem":{"name":"C. Four Segments","description":{"content":"You are given an array of _n_ integer numbers. Let _sum_(_l_, _r_) be the sum of all numbers on positions from _l_ to _r_ non-inclusive (_l_\\-th element is counted, _r_\\-th element is not counted). Fo","description_type":"Markdown"},"platform":"Codeforces","limit":{"time_limit":1000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"CF846C"},"statements":[{"statement_type":"Markdown","content":"You are given an array of _n_ integer numbers. Let _sum_(_l_, _r_) be the sum of all numbers on positions from _l_ to _r_ non-inclusive (_l_\\-th element is counted, _r_\\-th element is not counted). For indices _l_ and _r_ holds 0 ≤ _l_ ≤ _r_ ≤ _n_. Indices in array are numbered from 0.\n\nFor example, if _a_ = \\[ - 5, 3, 9, 4\\], then _sum_(0, 1) =  - 5, _sum_(0, 2) =  - 2, _sum_(1, 4) = 16 and _sum_(_i_, _i_) = 0 for each _i_ from 0 to 4.\n\nChoose the indices of three delimiters _delim_0, _delim_1, _delim_2 (0 ≤ _delim_0 ≤ _delim_1 ≤ _delim_2 ≤ _n_) and divide the array in such a way that the value of _res_ = _sum_(0, _delim_0) - _sum_(_delim_0, _delim_1) + _sum_(_delim_1, _delim_2) - _sum_(_delim_2, _n_) is maximal.\n\nNote that some of the expressions _sum_(_l_, _r_) can correspond to empty segments (if _l_ = _r_ for some segment).\n\n## Input\n\nThe first line contains one integer number _n_ (1 ≤ _n_ ≤ 5000).\n\nThe second line contains _n_ numbers _a_0, _a_1, ..., _a__n_ - 1 ( - 109 ≤ _a__i_ ≤ 109).\n\n## Output\n\nChoose three indices so that the value of _res_ is maximal. If there are multiple answers, print any of them.\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"CF846C","tags":["brute force","data structures","dp"],"sample_group":[["3\n-1 2 3","0 1 3"],["4\n0 0 -1 0","0 0 0"],["1\n10000","1 1 1"]],"created_at":"2026-03-03 11:00:39"}}