Inequality Satisfying Subsequences

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

요약
양의 정수 수열에서 세 원소가 삼각형을 이루는 부분수열이 없는 비어 있지 않은 부분수열의 개수를 998244353으로 나눈 나머지로 구한다. n은 7000 이하이다.
난이도

어려움10점 중 9점

유형
조합론, 정렬, 투 포인터, 수학
정답자
아직 제출이 없습니다

문제

A sequence of three positive integers \[a,b,c]\[a, b, c] is called a triangle if a+b>ca+b>c holds when reordered such that a≤b≤ca \leq b \leq c.

A sequence of positive integers is triangle-free if no subsequence of length 33 forms a triangle.

Given a sequence of positive integers LL, count how many non-empty subsequences of LL are triangle-free. As the answer may be very large, you are only required to find the value modulo 998,244,353998 \\, 244 \\, 353.

입력

The first line contains a single integer nn (1≤n≤7,0001 \leq n \leq 7\\,000) --- the size of the input sequence.

The second line contains nn integers L_1,L_2,⋯ ,L_nL\_1, L\_2, \cdots, L\_n (1≤L_i≤1091 \leq L\_i \leq 10^9) --- the elements of the sequence LL.

출력

Output the number of non-empty triangle-free subsequences modulo 998,244,353998 \\, 244 \\, 353 on one line.

예제3

  1. 예제 1

    입력
    10
    1 2 3 4 5 6 7 8 9 10
    
    예상 출력
    173
    
  2. 예제 2

    입력
    6
    9 6 7 8 4 4
    
    예상 출력
    23
    
  3. 예제 3

    입력
    10
    1 3 9 27 81 243 729 2187 6561 19683
    
    예상 출력
    1023