IMO

시간 제한6초메모리 제한2048 MB

요약
M개 문제와 최대 K점으로 구성된 N명의 점수가 주어질 때, 총점 순위가 유일하게 결정되도록 공개해야 하는 최소 점수 개수를 구한다.
난이도

보통10점 중 6점

유형
정렬, 그리디, 구현
정답자
아직 제출이 없습니다

문제

The International Mathematics Olympiad (IMO) is a maths competition for high school students that is held every year. The 2025 edition of the IMO takes place at the same time as the EGOI. As you are reading this, both contest days of the IMO have ended and the grading is probably almost done as well. Unlike programming competitions like the EGOI, the grading is done by hand, which is a long and arduous process.

This year the IMO had MM problems (numbered from 00 to M−1M-1), and each problem is worth a maximum of KK points. There were NN contestants taking part in the contest. The iith contestant received a score of a_i,ja\_{i,j} on problem jj, where a_i,ja\_{i,j} is an integer between 00 and KK, inclusive. The ranking of the contestants is determined by the total score of each contestant, with ties broken by the contestants' indices. More formally, contestant xx ranks higher than contestant yy if:

  • either the total score of contestant xx is bigger than the total score of contestant yy,
  • or their total scores are the same and x<yx < y.

In order to release the final ranking, the organizers need to publish some of the values a_i,ja\_{i,j}. If a value is unpublished, it is only known that it is an integer between 00 and KK, inclusive.

The organizers want to reveal as few of the values a_i,ja\_{i,j} as possible. At the same time, they need to make sure that everyone knows the correct final ranking. In other words, they must reveal a set of values such that the only ranking consistent with it is the correct one.

Find the smallest SS such that it is possible to reveal SS of the values a_i,ja\_{i,j} in a way that uniquely determines the full ranking of the contestants.

입력

The first line contains three integers NN, MM, and KK: the number of contestants, the number of problems, and the maximum score of the tasks, respectively.

Then follow NN lines, where the iith line contains a_i,ja\_{i,j}. That is, the first of these contains a_0,0,a_0,1,…,a_0,M−1a\_{0,0}, a\_{0,1}, \ldots, a\_{0, M-1}, the second contains a_1,0,a_1,1,…,a_1,M−1a\_{1,0}, a\_{1,1}, \ldots, a\_{1, M-1}, and so on.

출력

Print one integer SS, the minimum number of scores that can be revealed so that the final ranking is uniquely determined.

제한

  • 2≤N≤20,0002 \leq N \leq 20\\,000.
  • 1≤M≤1001 \leq M \leq 100.
  • 1≤K≤1001 \leq K \leq 100.
  • 0≤a_i,j≤K0 \leq a\_{i,j} \leq K for every pair i,ji,j where 0≤i≤N−10 \leq i \leq N-1 and 0≤j≤M−10\leq j \leq M-1.

예제4

  1. 예제 1

    입력
    4 6 7
    7 7 0 2 7 0
    7 3 0 7 2 1
    7 0 0 7 0 0
    7 7 7 7 7 1
    
    예상 출력
    20
    
  2. 예제 2

    입력
    2 1 1
    1
    0
    
    예상 출력
    1
    
  3. 예제 3

    입력
    2 2 7
    7 4
    7 0
    
    예상 출력
    2
    
  4. 예제 4

    입력
    2 2 1
    0 1
    1 0
    
    예상 출력
    2