POI

Interview

Time limit1sMemory limit256 MB

Summary
Each problem's value is the count of contestants who missed it; report Philip's total score and his rank using the four tiebreak terms.
Level

Easy3 of 10

Topics
Implementation, Array, Sorting, Simulation
Solved
No attempts yet

Problem

The scoring system of the Plovdiv Informatics Olympiad is very unusual. The contest has N contestants and T problems. There is no partial credit, so a contestant either solves a problem completely or fails it completely.

The point value of each problem equals the number of contestants who did not solve it, so a problem's value is only fixed once the contest ends. A contestant's score is the sum of the point values of the problems they solved.

Before the contest, each contestant is assigned a distinct ID from 1 to N. Philip's ID is P. A contestant's rank is defined as the sum of the following four terms:

  • the number of contestants with a strictly higher score,
  • the number of contestants with the same score who solved more problems,
  • the number of contestants with the same score and the same number of solved problems but a smaller (earlier) ID,
  • and 1.

Given the final results, write a program that computes Philip's score and rank.

Input

Read the following from standard input:

  • The first line contains N, T, and P separated by spaces.
  • Each of the next N lines describes whether a contestant solved each problem. The k-th line describes the contestant with ID k and contains T space-separated integers, each 0 or 1. If the i-th integer is 1, that contestant solved problem i; if it is 0, they did not.

Constraints:

  • 1≤N≤20001 \le N \le 2000 (number of contestants)
  • 1≤T≤20001 \le T \le 2000 (number of problems)
  • 1≤P≤N1 \le P \le N (Philip's ID)

Output

Print Philip's final score and rank on one line, separated by a single space.

Hint

Problem 1 was left unsolved by 1 contestant, problem 2 by 2 contestants, and problem 3 by 4 contestants, so the point values are 1, 2, and 4 respectively.

As a result, contestant 1 earns 4 points; contestants 2 (Philip), 4, and 5 each earn 3 points; and contestant 3 earns 1 point.

Exactly 1 contestant (contestant 1) scored higher than Philip, and no one tied his score while solving more problems, so Philip's rank is 2.

Examples1

  1. Example 1

    Input
    5 3 2
    0 0 1
    1 1 0
    1 0 0
    1 1 0
    1 1 0
    
    Expected output
    3 2