#P15876. [ICPC 2026 NAC] Boss Rush
[ICPC 2026 NAC] Boss Rush
Description
Franklin is playing the latest trendy timed-action video game and is facing a boss rush: a trying gauntlet where he must defeat monsters (the bosses) to survive. His only ability, , is extremely powerful but very difficult to use.
Each boss attacks Franklin once every seconds; however, the bosses have their own before they begin their sequence of attacks, so that the boss attacks are staggered. More specifically, if is the starting delay of the boss, then that boss will attack at seconds
To defend himself, Franklin can parry an attack on the exact second it happens, instantly defeating the boss and ending all of its subsequent attacks. Franklin can only parry one attack at a time: if multiple bosses attack him simultaneously, he can parry at most one of those attacks.
Moreover, after parrying an attack Franklin becomes winded and cannot parry again during the next seconds. Formally, if Franklin parries an attack at second , the earliest moment that Franklin could parry another attack is at second .
Franklin has plenty of health and is unconcerned about the attacks of the bosses against him, but he'd like to end the fight as quickly as possible. Compute the minimum amount of time it would take Franklin to defeat all bosses if he parries optimally.
Input Format
The first line of input contains three space-separated integers , , and , where is the number of bosses, is the number of seconds Franklin must wait after parrying before parrying again, and is the number of seconds between two attacks by the same boss.
The next line of input contains space-separated integers , the starting delay of each boss in seconds.
Output Format
Print the number of seconds it takes Franklin to defeat all bosses if he parries optimally.
3 4 10
2 3 8
12
3 4 10
2 3 9
13
Hint
Explanation of Sample Input 1
The first boss attacks Franklin at second ; Franklin could parry the attack but chooses to bide his time and instead parry the attack of the second boss at second . He is now winded and cannot parry again before second .
The third boss attacks Franklin at second and Franklin parries the attack. He is winded again and cannot parry until second : just in time to parry the first boss's second attack, which ends the fight.
京公网安备 11011102002149号