Convex Sequence

AtCoder
IDagc049_d
Time2000ms
Memory256MB
Difficulty
Given are integers $N$ and $M$. Find the number, modulo $(10^9+7)$, of length-$N$ sequences $(A_1,A_2,\ldots,A_N)$ that consist of non-negative integers and satisfy the following conditions: * $A_1+A_2+\ldots +A_N = M$; * For every $i$ ($2 \leq i \leq N-1$), $2 A_i \leq A_{i-1} + A_{i+1}$. ## Constraints * $1 \leq N \leq 10^5$ * $1 \leq M \leq 10^5$ * All values in input are integers. ## Input Input is given from Standard Input in the following format: $N$ $M$ [samples]
Samples
Input #1
3 3
Output #1
7

The following seven sequences satisfy the conditions.

*   $0,0,3$
*   $0,1,2$
*   $1,0,2$
*   $1,1,1$
*   $2,0,1$
*   $2,1,0$
*   $3,0,0$
Input #2
10 100
Output #2
10804516
Input #3
10000 100000
Output #3
694681734
API Response (JSON)
{
  "problem": {
    "name": "Convex Sequence",
    "description": {
      "content": "Given are integers $N$ and $M$. Find the number, modulo $(10^9+7)$, of length-$N$ sequences $(A_1,A_2,\\ldots,A_N)$ that consist of non-negative integers and satisfy the following conditions: *   $A_1",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "agc049_d"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Given are integers $N$ and $M$. Find the number, modulo $(10^9+7)$, of length-$N$ sequences $(A_1,A_2,\\ldots,A_N)$ that consist of non-negative integers and satisfy the following conditions:\n\n*   $A_1...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments