Under construction

Still being built. Things may change

Team Work

Time limit1sMemory limit1024 MB

Summary
Given n students with per-problem solve times and a total contest time, find the most problems the team can solve when each student solves at most one and problems run one at a time.
Level

Medium5 of 10

Topics
Dynamic programming, Brute force
Solved
No attempts yet

Problem

The UCF Programming Teams have succeeded for over 40 years because of talented, dedicated students and experienced, skilled coaches. The coaches teach algorithms and team strategies, and the students compete in contests.

A team in the International Collegiate Programming Contest has three students. One major team strategy is deciding who solves which problem. The coaches need a program that answers this question. Write that program.

Given the number of students on a team, the number of problems, the time each student needs for each problem, and the total contest time, find the maximum number of problems the whole team can solve in the given time. Assume that:

  • A student can solve at most one problem in the entire contest. For example, suppose the contest lasts 5 hours and Student1 can solve Problem7 in 1 hour and Problem9 in 2 hours. Even though both problems fit in 3 hours, Student1 can still solve at most one problem.
  • The team has only one computer. While a student uses it, teammates cannot use it, so problems are solved one at a time. For example, suppose the contest lasts 5 hours, Student2 can solve Problem6 in 2 hours, and Student3 can solve Problem8 in 4 hours. Those two problems need 6 hours in total, so the 5-hour contest is not enough to solve both. Problems are not solved in parallel, even with several students.

Input

The first line contains three integers nn, pp, and tt.

  • nn (1≤n≤2001 \le n \le 200) is the number of students on the team.
  • pp (1≤p≤2001 \le p \le 200) is the number of problems in the set.
  • tt (1≤t≤1051 \le t \le 10^5) is the total time available.

The next nn lines each contain pp integers. Line ii describes student ii. The jj-th integer on that line is the time student ii needs to solve problem jj, and each value is between 00 and 10510^5, inclusive. A value of 00 means that student cannot solve that problem.

Output

Print the maximum number of problems the entire team can solve in the given time.

Examples2

  1. Example 1

    Input
    2 4 5
    2 5 3 4
    0 4 5 0
    
    Expected output
    1
    
  2. Example 2

    Input
    2 4 5
    1 5 1 1
    2 1 0 1
    
    Expected output
    2