Robot Upgrades

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

요약
N개의 부품에 0에서 M까지 업그레이드 횟수를 배정하되, i회 이상 업그레이드된 부품 수가 A_i 이하가 되도록 하는 배치의 수를 센다.
난이도

어려움10점 중 8점

유형
조합론, 동적 계획법, 수학
정답자
아직 제출이 없습니다

문제

The Kingdom of ICPC is being attacked by evil balloons! Fortunately, Morgan the robot is ready to defend the kingdom. In order to strengthen his power, there are NN parts, numbered from 11 to NN, that can be upgraded. Each part can be upgraded 00 to MM times (inclusive).

In order to save resources, there are MM restrictions, numbered from 11 to MM, in upgrading Morgan. For restriction ii, the number of parts that are upgraded at least ii times should not exceed A_iA\_i.

While planning on what upgrade should be applied to Morgan, Adrian wonders how many different upgrade configurations that satisfy all of the given restrictions. Two configurations are different if and only if there exists at least one part with a different number of upgrades applied to that part. Since the answer can be large, find the answer modulo 998,244,353998\\, 244\\, 353.

입력

Input begins with two integers NN MM (1≤N≤100,0001 ≤ N ≤ 100\\, 000; 1≤M≤101 ≤ M ≤ 10) representing the number of parts and the number of restrictions, respectively. The next line contains MM integers A_iA\_i (1≤A_i≤N1 ≤ A\_i ≤ N) representing the given restrictions. The integers in AA are given in non-increasing order, i.e. A_1≥A_2≥⋯≥A_MA\_1 ≥ A\_2 ≥ \dots ≥ A\_M.

출력

Output an integer in a single line, representing the number of different upgrade configurations that satisfy all of the given restrictions modulo 998,244,353998\\, 244\\, 353.

예제3

  1. 예제 1

    입력
    3 5
    2 2 1 1 1
    
    예상 출력
    64
    
  2. 예제 2

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

    입력
    16 8
    16 16 8 4 4 2 1 1
    
    예상 출력
    720246211