포럼
문제 ICPC00264

G. Game of Gnomes

설명

The enemy and their massive army is approaching your fortress, and all you have to defend it is a legion of guardian gnomes. There is no hope of winning the battle, so your focus will instead be on causing as much damage as possible to the enemy.

You have \(n\) gnomes at your disposal. Before the battle, they must be divided into at most \(m\) non-empty groups. The battle will then proceed in turns. Each turn, your gnomes will attack the enemy, causing one unit of damage for each living gnome. Then the enemy will attack by throwing a lightning bolt at one of the \(m\) groups. The lightning bolt kills \(k\) of the gnomes in that group, or all of them if the number of living gnomes in the group is less than \(k\). The battle ends when all gnomes are dead. The enemy will always throw the lightning bolts in an optimal way such that the total damage caused by the gnomes is minimized.

Now you wonder, what is the maximum amount of damage you can cause to the enemy if you divide the gnomes into groups in an optimal way?

For example, if as in Sample Input 1 you have \(n=10\) gnomes that are to be divided into \(m=4\) groups, and the lightning bolt does at most \(k=3\) damage, then an optimal solution would be to create one large group of size \(7\) and three small groups of size \(1\). In the first round, you cause \(10\) damage and the lightning bolt reduces the large group by \(3\). In the next round, you cause \(7\) damage and the large group is reduced down to size \(1\). In the remaining four rounds you do \(4\), \(3\), \(2\), and \(1\) damage respectively and the lightning bolt removes one group each round. In total you do \(10+7+4+3+2+1 = 27\) damage.

제약
입력 형식

The input consists of a single line containing the three integers \(n\), \(m\), and \(k\) (\(1 \le n \le 10^9\), \(1 \le m, k \le 10^7\)), with meanings as described above.

출력 형식

Output the maximum amount of damage you can cause to the enemy.

예제 1
입력
10 4 3
출력
27
예제 2
입력
5 10 100
출력
15
문제 정보

생성자가 기록되지 않았습니다.

출처 ICPC NCPC 2019

평가 및 의견

G. Game of Gnomes

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 1 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

G. Game of Gnomes

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8