QOJ.ac

QOJ

実行時間制限: 1 s メモリ制限: 1024 MB 満点: 100 ハック可能 ✓

#18111. 호반우가 학교에 지각한 이유 1

統計

경북대학교의 마스코트이자 따봉 요정인 호반우는 오늘도 수업을 듣기 위해 경북대학교 정문을 지나치던 도중 정체불명의 차원문에 휘말려 이세계로 오게 되었다.

이세계의 신인 당신이 호반우가 마왕을 물리치고 지구로 돌아가 학교에 지각하지 않도록 도와주자!

호반우의 현재 스탯인 힘($STR$), 민첩($DEX$), 지능($INT$), 운($LUK$)에 해당하는 $4$가지 수가 주어진다.

$4$가지 스탯 중 하나의 수치를 $1$씩 올릴 수 있는 축복을 여러 번 사용해 호반우의 평균 스탯 수치를 $N$ 이상으로 만들려고 할 때 최소 몇 번의 축복을 사용해야 하는지 구해보자.

Input

첫 번째 줄에 $STR,\,DEX,\,INT,\,LUK$과 $N$이 공백을 두고 주어진다. $(1 \le STR,\,DEX,\,INT,\,LUK,\,N \le 100)$

입력되는 모든 수는 양의 정수이다.

Output

호반우의 평균 스탯 수치를 $N$ 이상으로 만들기 위해 사용해야 할 축복의 최소 횟수를 출력한다.

Examples

Input 1

100 100 100 100 1

Output 1

0

Input 2

100 1 100 1 100

Output 2

198

Input 3

1 1 1 1 1

Output 3

0

Input 4

100 100 100 100 100

Output 4

0

Input 5

99 100 99 100 99

Output 5

0

Input 6

1 1 1 1 100

Output 6

396

Input 7

1 100 1 100 1

Output 7

0

Note

호반우의 평균 스탯 수치는 다음과 같이 구할 수 있습니다.

$$ \begin{aligned} \frac{STR+DEX+INT+LUK}{4} \end{aligned} $$

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.