Logo
(追記) (追記ここまで)

11013번 - The Missing Permutation 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
15 초 256 MB447531.250%

문제

Little Tomato has a permutation P from 1 to n on a board. Each day, he swaps some numbers in P to form a new permutation P', and then tries to find the longest increasing subsequence (LIS) of P'. He believes that he can eventually find a faster algorithm for calculating LIS.

One day after an earthquake, some of the numbers in the permutation P has dropped off the board. Little tomato soon wondered, if he puts all the numbers back in a certain way, what will be the largest possible length of the LIS of the recovered permutation?

입력

First line of the input contains an integer T (1 ≤ T ≤ 100) denoting the number of the test cases. For each test case, the first line contains an integer n (1 ≤ n ≤ 105) indicating the length of the permutation. The next line contains a incomplete permutation a1, a2, ··· , an. If ai = 0, that means the number originally at the i-th position has dropped. The input will be always valid, and less than 10MB.

출력

For each test case, output the maximum possible length of the LIS of the recovered permutation.

제한

예제 입력 1

4
5
0 0 0 0 0
10
1 2 3 4 0 0 0 0 9 10
14
1 0 3 0 5 0 7 0 9 0 11 0 13 0
9
3 0 0 0 7 8 9 0 0

예제 출력 1

5
10
14
7

힌트

출처

ICPC > Regionals > Asia Pacific > Taiwan > Taiwan Online Programming Contest > TOPC 2015 H번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /