oj mrJudge
Toggle navigation
  • Login
    • Forget Password
      Login
User Image

Hello, Stranger

Guest
  • Analysis Mode
  • Problems
    • All Problems
    • Latest Problems
  • Join Us Now
  • Registration
  • Contact Us
  • Infomation
  • About
    • Terms of Use
    • Technical Specifications
    • Credits

morepaths Batch , stdin/stdout

Registered Users Only

Please login to utilize this feature.

Do note that this website only supports submissions in C++.

morepaths.html

Problem Description

Rar the Cat is solving a weird puzzle. He has a grid of N by M squares, each square (i, j) containing an integer Ai,j.

He starts off on the square on the top-left hand corner, and needs to get to the square at the bottom-right corner, by only moving either down or right at each step. He sums up the integers on all the squares he has been on, and that is deemed as the "score" of that path.

He traverses through all possible paths (there are N+M-2CN-1 of them), and records all of the scores onto a piece of paper. He wants to find out what is the Kth largest number on the piece of paper.

Input

The first line of input contains three integers, N, M and K.

The next N lines of input contain M integers each, describing the grid.

Output

The output should contain one integer, the Kth largest value of a path.

Limits

1 ≤ K ≤ N+M-2CN-1, 0 ≤ Ai,j ≤ 109.

Subtask 1 (15%): 1 ≤ N, M ≤ 10, 1 ≤ K ≤ 1000.

Subtask 2 (24%): 1 ≤ N, M ≤ 200, K = 1.

Subtask 3 (23%): 1 ≤ N, M ≤ 200, 1 ≤ K ≤ 2.

Subtask 4 (27%): 1 ≤ N, M, K ≤ 200.

Subtask 5 (11%): 1 ≤ N, M ≤ 500. 1 ≤ K ≤ 1000.

Subtask 6 (0%): Sample Testcases

Sample Testcase 1

Input

2 2 2
1 2
3 4

Output

7

Sample Testcase 2

Input

3 5 10
3 4 1 5 1
2 3 0 1 3
3 4 1 1 9

Output

21

Tags

Dynamic Programming

Subtasks and Limits

Subtask Score #TC Time Memory Scoring
115221s256MBMinimum
224201s256MBMinimum
323411s256MBMinimum
427621s256MBMinimum
5111021s256MBMinimum
6021s256MBMinimum

Judge Compile Command

g++-8 ans.cpp -o morepaths -Wall -Wshadow -static -O2 -lm -m64 -s -w -std=gnu++17 -fmax-errors=512

Accepted Submissions

subIDUserTimeMax Time

Past Submissions

subIDUserTimeScore
mrJudge 09.05.20
Copyright © 2020 mrJudge. All rights reserved.