+1 and -1

AtCoder
IDarc185_b
Time2000ms
Memory256MB
Difficulty
You are given an integer sequence $A = (A_1, A_2, \dots, A_N)$ of length $N$. You can perform the following operation any number of times, possibly zero: * Choose an integer pair $(i, j)$ satisfying $1 \leq i \lt j \leq N$, and replace $A_i$ with $A_i + 1$ and $A_j$ with $A_j - 1$. Determine whether it is possible to make $A$ a non-decreasing sequence through the operations. You are given $T$ test cases. Solve each of them. ## Constraints * $1 \leq T \leq 2 \times 10^5$ * $2 \leq N \leq 2 \times 10^5$ * $0 \leq A_i \leq 10^9$ * The sum of $N$ over all test cases is at most $2 \times 10^5$. * All input values are integers. ## Input The input is given from Standard Input in the following format. Here, $\mathrm{case}_i$ denotes the $i$\-th test case. $T$ $\mathrm{case}_1$ $\mathrm{case}_2$ $\vdots$ $\mathrm{case}_T$ Each test case is given in the following format: $N$ $A_1$ $A_2$ $\dots$ $A_N$ [samples]
Samples
Input #1
3
3
1 7 5
2
9 0
10
607 495 419 894 610 636 465 331 925 724
Output #1
Yes
No
Yes

In the first test case, you can make $A$ into a non-decreasing sequence by performing the following operations:

*   Choose $(i, j) = (1, 2)$. After the operation, $A$ is $(2, 6, 5)$.
*   Choose $(i, j) = (1, 2)$. After the operation, $A$ is $(3, 5, 5)$.

In the second test case, you cannot make $A$ into a non-decreasing sequence no matter how you perform the operations.
API Response (JSON)
{
  "problem": {
    "name": "+1 and -1",
    "description": {
      "content": "You are given an integer sequence $A = (A_1, A_2, \\dots, A_N)$ of length $N$.   You can perform the following operation any number of times, possibly zero: *   Choose an integer pair $(i, j)$ satisfy",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "arc185_b"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "You are given an integer sequence $A = (A_1, A_2, \\dots, A_N)$ of length $N$.  \nYou can perform the following operation any number of times, possibly zero:\n\n*   Choose an integer pair $(i, j)$ satisfy...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments