Logo
(追記) (追記ここまで)

19828번 - Berland University 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB40191854.545%

문제

There are $t$ students studying in the best university of Berland. They only study programming in Berland, so there is only one subject. Each student must attend the lectures.

The entire course consists of $n$ lectures. It is known that a student who visits at least $k$ of them will pass the course.

There are only two auditoriums in the university, one has space for $a$ people and the other one --- for $b$ people. To make it comfortable, the administration decided that in odd weeks the lectures will be in the first auditorium, and in the even weeks --- in the second auditorium. So the first lecture will be in the 1-st auditorium, the second lecture in the 2-nd one, the third in the 1-st one again, and so on.

The sizes of the auditoriums are small so it might not be possible for all students to attend at least $k$ lectures. They ask you to count the maximum number of students that can pass the course.

입력

The first line contains five integers:

  • $t$ --- the number of students;
  • $n$ --- the number of lectures;
  • $a$ --- the size of the first auditorium;
  • $b$ --- the size of the second auditorium;
  • $k$ --- the minimal number of lectures to pass the course.

The limits are: 1ドル \leq t, n, a, b, k \leq 10^9$.

출력

Print a single integer --- the maximal number of students that can attend at least $k$ lectures and thus pass the course.

제한

예제 입력 1

10 3 4 4 3

예제 출력 1

4

예제 입력 2

10 3 4 4 5

예제 출력 2

0

예제 입력 3

100000 100000 100000 100000 1

예제 출력 3

100000

예제 입력 4

5 4 5 3 3

예제 출력 4

5

예제 입력 5

100 9 6 3 6

예제 출력 5

7

힌트

In the fourth sample, 5 students can pass the course. Here's one possible strategy:

  1. Students 1ドル,ドル 2ドル,ドル 3ドル,ドル 4ドル,ドル 5ドル$ visit the first lecture.
  2. Students 1ドル,ドル 3ドル$ visit the second lecture.
  3. Students 1ドル,ドル 2ドル,ドル 3ドル,ドル 4ドル,ドル 5ドル$ visit the third lecture.
  4. Students 2ドル,ドル 4ドル,ドル 5ドル$ visit the fourth lecture.

This way each of these 5 students can attend at least 3 lectures.

출처

Olympiad > Russian Olympiad in Informatics > Russia Team High School Programming Contest > Russia Team High School Programming Contest 2018 L번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /