PRESS HERE to read a great passage
四季有更迭之時,晴雨亦有更迭之時。世上並不存在永遠的暴風雨,永遠的風和日禮。人生中,有歡樂的時刻,亦有悲痛的時刻。若人生只是一帆風順,人便不會學會珍惜,若人生只是災禍連連,人邊不會有生存的慾望。又是觀之,人生裏同時存在著順境及逆境,才談得上為人生。
人生中,人總會渴望得到某些東西。有的是比賽的獎項,有的是成績,有的榮譽。可嘆的是,人生從不會只是如流水般順暢,人生總有失意之時。面臨這是逆境之時,我們不能輕易放棄,氣餒。或許,這是時刻是人從錯誤中學習的良機。我們不能單單埋怨這是一場來自命運的玩弄,相反要擁抱它,學會當中蘊藏著的道理。
在雨中跳舞,帶著鼓勵的寓意。表達著人不只是等待困難過去,而是在逆境或挑戰中保持樂觀、積極尋找快樂與成長,享受當下,從中找到力量,而非被困境擊倒。總括而言,生活不是等待風暴過去,而是學習如何在雨中跳舞。
能從學習 ”Hello World” 走到現在,相信大家亦遇過不同的困難,不同處在瓶口位的時候。這些時刻是大家也曾經歷過的。有奪獎的時刻,亦會有氣餒的時刻。我們不能輕易放棄,而是要學會在這常暴風雨下跳著華麗的舞步,享受著,學習著。
By LMC ("erm... fair passage... no comment...")
The annual Hong Kong Olympiad In Dancing Industry (HKOI) has begun. The contest format requires a team of $N$ dancers to perform a relay routine on a long straight runway.
Alice’s team has prepared for a long time, and now it's their turn. However, a sudden storm has caused $M$ water puddles to form along the runway in a fixed sequence. The $i$ th puddle has a length of $L_i$.
However, the show must go on. Alice's Team decided not to give up due to the rain. They decided to embrace the rain and continue to complete their routine.
To complete the routine, the $M$ puddles must be divided among the $N$ dancers according to the following rules:
1. Contiguous Segment: The puddles are arranged in a specific order and cannot be rearranged. Each dancer must handle a contiguous segment of puddles. (e.g., Dancer 1 takes puddles 1 to 3, Dancer 2 takes puddles 4 to 6, etc.).
2. No Division: Every puddle must be assigned to exactly one dancer. Dancers cannot split the puddle into smaller puddles and share it.
As the captain, Alice wants to distribute the work such that the team is as safe as possible. Specifically, she wants to minimize the maximum length of water puddle experienced by any single dancer.
Help Alice figure out: What is the lowest possible value for the maximum total puddle length assigned to a single dancer?
Input
The first line consists of 2 integers, $N$, $M$.($1\le N, M \le 10^5$)
The following line consists of $M$ integers $L_1,L_2,...,L_M$, where $L_i$ represents the length of the $i$ th water puddle. ($1\le L_i \le 10^9$ for all $1 \le i \le M$)
Output
The output consists of a single integer, the lowest possible value for the maximum total puddle length assigned to a single dancer.
Subtasks
Subtask 1: $N$ = 1 (5 pts)
Subtask 2: $M$ = 1 (5 pts)
Subtask 3: $1 \le N, M, L_i \le 100$ (60 pts)
Subtask 4: No additional constraints (30 pts)
Hint
Remember to use long long int instead of int, as the answer may exceed $2^{31}-1$
Sample Test Cases
| Input | Output | |
|---|---|---|
| 4 7 51 11 52 47 42 2 19 |
63 | |
The four dancers will split the water puddles in the following method |
||
| 3 5 44 39 18 17 36 |
57 | |
Scoring: Per Subtask
Authored by wy23918
Appeared in WYHK 2026 Mini Comp 0 🗣️🙊🇫🇷🥖🤮 🟥🟦3️⃣2️⃣1️⃣🎊 8️⃣0️⃣🧙♀️ 🇩🇪🏙️🌍🦠🧑💻💃🌧️