QOJ.ac

QOJ

時間限制: 1 s 記憶體限制: 256 MB 總分: 100 可 Hack ✓

#19987. 우리를 구해 줄 건가요?

统计

영웅인 당신은 세계의 최종 보스 Irisu와 싸우려 한다. 영웅인 당신에게는 세 가지 캐릭터 “능력”이 있다. 신체 $B$, 정신 $M$, 지능 $I$이며, 종합 능력 $S$는 이 능력들의 기하평균으로 계산된다. 즉, $S=\sqrt[3]{BMI}$이다. 안타깝게도 지난 보스와의 전투에서 패배했기 때문에 지금 모든 능력은 $0$이다.

Irisu를 물리치려면 종합 능력이 신비한 부등식 $(S+5)(S+1)(S+4)\ge X$를 만족해야 한다. 이 부등식은 지난 전투 후 거대한 토마토 속에서 발견한 고대 두루마리에 적혀 있다. 능력을 올릴 수 있는 유일한 방법은 암흑 연금술사 Skyly에게 능력 물약을 사는 것이다. Skyly는 $N_B+N_M+N_I$개의 물약을 판매하고 있다. 처음 $N_B$개는 신체 물약, 다음 $N_M$개는 정신 물약, 마지막 $N_I$개는 지능 물약이다. $i$번째 물약은 $P_i$달러이며 해당 능력을 $E_i$만큼 올려 준다.

세계와 지갑을 모두 구하기 위해, 최종 보스를 물리칠 능력 물약을 사는 데 필요한 최소 총비용을 구하려 한다.

입력

첫 줄에는 네 정수 $X,N_B,N_M,N_I$가 주어진다. 다음 $N_B+N_M+N_I$개 줄 중 $i$번째 줄에는 두 정수 $P_i,E_i$가 주어진다.

  • $0\le X\le10^9$
  • $0\le N_B,N_M,N_I\le30$
  • $0\le P_i,E_i\le10^9$ 모든 $1\le i\le N_B+N_M+N_I$에 대해 성립한다.

출력

최종 보스를 물리칠 능력 물약을 사는 데 필요한 최소 총비용을 출력한다. Skyly에게서 모든 물약을 사도 충분히 강해질 수 없다면 DEAREST DROP을 출력한다.

예제

입력 1

31 4 1 5
9 2
6 5
3 5
8 9
7 9
3 2
3 8
4 6
2 6
4 3

출력 1

12

입력 2

5566 2 1 0
0 999999999
999999999 0
0 0

출력 2

DEAREST DROP

입력 3

50216 2 2 2
1 20
1 30
10 42
20 43
15 18
17 19

출력 3

29

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.