아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Topical

면접 대비

시간 제한1초메모리 제한1024 MB

요약
각 모듈은 k개 주제에 대한 최소 지식 요건을 만족해야 이수할 수 있고 이수하면 지식이 늘어난다. 어떤 순서로 이수할 때 완료할 수 있는 모듈 수의 최댓값을 구한다.
난이도

보통10점 중 7점

유형
그리디, 정렬, 힙, 배열
정답자
아직 제출이 없습니다

문제

Benson the Rabbit is attending pilot school!

He has nn modules to complete, numbered from 11 to nn. There are kk topics in flying numbered from 11 to kk. As Benson is new to flying, he starts with zero knowledge in each topic.

Each of these nn modules have a knowledge requirement to complete them. In particular, to complete module ii, Benson requires at least r\[i]\[j]r\[i]\[j] knowledge of topic jj for all topics jj.

Completing a module also allows Benson to gain knowledge in some topics. After completing module ii, he will gain u\[i]\[j]u\[i]\[j] knowledge in topic jj.

Formally, let Benson’s knowledge in topic jj be p\[j]p\[j]. Initially, p\[j]=0p\[j] = 0 for all jj. He can only complete a module ii if p\[j]≥r\[i]\[j]p\[j] ≥ r\[i]\[j] for every topic jj. After completing module ii, the value of p\[j]p\[j] increases by u\[i]\[j]u\[i]\[j] for each topic jj.

Benson may complete the modules in any order, but each module may only be completed at most once. Help Benson determine the maximum number of modules he can complete.

입력

The first line of input contains 22 space-separated integers, nn and kk.

Then, nn lines will follow. The ii-th (1≤i≤n1 ≤ i ≤ n) of these lines contains kk spaced integers r\[i]\[1],r\[i]\[2],…,r\[i]\[k]r\[i]\[1], r\[i]\[2], \dots , r\[i]\[k], denoting the knowledge requirements to complete module ii.

Another nn lines follow. The ii-th (1≤i≤n1 ≤ i ≤ n) of these lines contains kk spaced integers u\[i]\[1],u\[i]\[2],…,u\[i]\[k]u\[i]\[1], u\[i]\[2], \dots , u\[i]\[k], denoting the knowledge gained after completing module ii.

출력

The output should contain one integer, the maximum number of modules Benson can complete.

제한

  • 1≤n,k≤1061 ≤ n, k ≤ 10^6
  • n⋅k≤106n \cdot k ≤ 10^6
  • 0≤u\[i]\[j],r\[i]\[j]≤1090 ≤ u\[i]\[j], r\[i]\[j] ≤ 10^9 (for all 1≤i≤n1 ≤ i ≤ n and 1≤j≤k1 ≤ j ≤ k).

예제3

  1. 예제 1

    입력
    3 3
    0 0 0
    7 9 2
    7 8 9
    7 8 2
    7 7 7
    8 10 9
    
    예상 출력
    1
    
  2. 예제 2

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

    입력
    5 5
    14 11 15 7 15
    0 0 0 0 0
    9 9 14 2 13
    4 3 6 1 0
    2 4 7 0 0
    5 5 0 0 13
    4 4 7 1 0
    4 1 0 2 1
    2 5 0 2 1
    4 0 7 2 12
    
    예상 출력
    4