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

24475번 - Self Study 서브태스크다국어

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

문제

In the third semester of the first grade of JOI High School, $N$ courses are given for $M$ weeks from the first week to the $M$-th week. The courses are numbered from 1ドル$ to $N$. In each week, $N$ classes are given. The $i$-th class in each week is a class for Course $i$.

Bitaro is a student of the first grade. In each of the $N \times M$ classes, he takes one of the following actions.

  • Action 1: Bitaro attends the class. If he attends a class for Course $i$ (1ドル ≤ i ≤ N$), the comprehension level of Course $i$ will be increased by $A_i$.
  • Action 2: Bitaro does not attend the class. Instead, he chooses any one of the courses, and studies for the chosen course by himself. If he studies for Course $i$ (1ドル ≤ i ≤ N$) by himself for the duration of a class, the comprehension level of Course $i$ will be increased by $B_i$.

In the beginning, the comprehension level of every course is 0ドル$. Since Bitaro wants to practice competitive programming after school, he will not study outside the duration of the classes. When all the classes in the third semester finish, the final examination will be held.

Bitaro does not want to get a failing grade. Therefore, he wants to maximize the minimum comprehension level of the courses at the moment of the final examination.

Given the length of the semester, the number of the courses, and the incremental values of the comprehension levels, write a program which calculates the maximum possible value of the minimum comprehension level of the courses at the moment of the final examination.

입력

Read the following data from the standard input. Given values are all integers.

$\begin{align*} & N,円M \\ & A_1 ,円 A_2 ,円 \cdots ,円 A_N \\ & B_1 ,円 B_2 ,円 \cdots ,円 B_N\end{align*}$

출력

Write one line to the standard output. The output should contain the maximum possible value of the minimum comprehension level of the courses at the moment of the final examination.

제한

  • 1ドル ≤ N ≤ 300,000円$.
  • 1ドル ≤ M ≤ 1,000円,000円,000円$.
  • 1ドル ≤ A_i ≤ 1,000円,000円,000円$ (1ドル ≤ i ≤ N$).
  • 1ドル ≤ B_i ≤ 1,000円,000円,000円$ (1ドル ≤ i ≤ N$).

서브태스크

번호배점제한
110

$M = 1$.

225

$N \times M ≤ 300,000円,ドル $A_i = B_i$ (1ドル ≤ i ≤ N$).

327

$N \times M ≤ 300,000円$.

429

$A_i = B_i$ (1ドル ≤ i ≤ N$).

59

No additional constraints.

예제 입력 1

3 3
19 4 5
2 6 2

예제 출력 1

18

For example, if Bitaro studies in the following way, the compehension level of Course 1ドル,ドル 2ドル,ドル 3ドル$ will be 19ドル,ドル 18ドル,ドル 19ドル,ドル respectively.

  • In the first week, at the time of Course 1ドル,ドル he studies for Course 2ドル$ by himself.
  • In the first week, at the time of Course 2ドル,ドル he studies for Course 2ドル$ by himself.
  • In the first week, at the time of Course 3ドル,ドル he attends the class for Course 3ドル$.
  • In the second week, at the time of Course 1ドル,ドル he attends the class for Course 1ドル$.
  • In the second week, at the time of Course 2ドル,ドル he studies for Course 3ドル$ by himself.
  • In the second week, at the time of Course 3ドル,ドル he attends the class for Course 3ドル$.
  • In the third week, at the time of Course 1ドル,ドル he studies for Course 3ドル$ by himself.
  • In the third week, at the time of Course 2ドル,ドル he studies for Course 2ドル$ by himself.
  • In the third week, at the time of Course 3ドル,ドル he attends the class for Course 3ドル$.

Since the minimum comprehension level of the courses cannot be larger than or equal to 19ドル,ドル output 18ドル$. This sample input satisfies the constraints of Subtasks 3, 5.

예제 입력 2

2 1
9 7
2 6

예제 출력 2

7

This sample input satisfies the constraints of Subtasks 1, 3, 5.

예제 입력 3

5 60000
630510219 369411957 874325200 990002527 567203997
438920902 634940661 593780254 315929832 420627496

예제 출력 3

41397427274960

This sample input satisfies the constraints of Subtasks 3, 5.

예제 입력 4

4 25
1 2 3 4
1 2 3 4

예제 출력 4

48

This sample input satisfies the constraints of Subtasks 2, 3, 4, 5.

힌트

출처

Olympiad > Japanese Olympiad in Informatics > JOI 2021/2022 2번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

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

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