시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB49211434.146%

문제

The main movie theater of the city consists of a single auditorium with rows of comfortable padded seats. Surprisingly, the comfortness of seats are not necessarily equal. Precisely, each seat has its own comfort value which is a non-negative integer number. A seat is more comfortable than another seat if its comfort value is larger. It is only possible to enter a row from the left side of the auditorium. Assume the seats in a row are numbered 1 to m from left to right. When a person enters a row, he/she always sits on the most comfortable seat which is free and accessible to him/her. If he/she sits at seat i, he/she blocks other persons coming later to sit on seats i+ 1 to m. If there are more than one free and accessible seat being the most comfortable, he/she sits on the leftmost one. The owner of the movie theater plans to improve the comfortness of some seats to have more audiences in the auditorium. Improving one unit in the comfortness of a seat costs some fix value. With the budget available, the owner knows the total improvement over all seats must not exceed a value k. Help the owner find the best way to improve the comfortness of seats by at most k units in total to have the maximum number of audiences in the auditorium.

입력

The first line contains three non-negative integers n, m, and k (1 ≤ n·m ≤ 3×105, 0 ≤ k ≤ 1012) which are the number of rows, the number of seats in each row, and the total comfortness that can be added to all seats. The next n lines describe the comfort values of seats; each line contains m non-negative integers not more than 106 denoting the comfort values of seats from left to right for a row.

출력

Print a single line containing the maximum number of audiences.

예제 입력 1

2 3 10
10 1 12
8 3 6

예제 출력 1

5

예제 입력 2

1 4 6
9 8 10 8

예제 출력 2

3

예제 입력 3

1 3 2
10 10 10

예제 출력 3

2

출처

ICPC > Regionals > Asia West Continent > Iran > Tehran Site 2018 C번