[PA 2024] Bardzo Ulubiony Ciąg

Luogu
IDLGP10366
Time3000ms
Memory1024MB
DifficultyP5
2024PA(波兰)
**题目译自 [PA 2024](https://sio2.mimuw.edu.pl/c/pa-2024-1/dashboard/) Runda 5 [Bardzo Ulubiony Ciąg](https://sio2.mimuw.edu.pl/c/pa-2024-1/p/buc/),感谢 Macaronlin 提供翻译** 给定长度为 $n$ 的整数数组 $a$,$a$ 的所有子区间和形成长度为 $\frac{n(n+1)}{2}$ 的数组 $b$,子区间和按区间开始下标的递增顺序排列,如果区间开始下标相同,则按区间结束递增顺序排列。 对于新形成的数组 $b$,求满足 $b_i+b_j+b_k=0\ (i<j<k)$ 的 $(i,j,k)$ 对数。 ## Input 第一行一个整数 $n\ (1\le n\le 500)$,表示数组 $a$ 的长度。 第二行 $n$ 个整数 $a_1,a_2,\ldots,a_n\ (|a_i|\le 20\,000)$,表示数组 $a$。 ## Output 一行一个整数,表示数组 $b$ 中满足 $b_i+b_j+b_k=0\ (i<j<k)$ 的 $(i,j,k)$ 对数。 [samples] ## Background PA 2024 5C1 ## Note **样例解释 1** 数组 $b$ 为 $[7,3,1,-4,-6,-2]$,只有 $3,1,-4$ 这三个不同元素满足,所以答案为 $1$。 **样例解释 2** 数组 $b$ 为 $55$ 个 $0$,任选三个 $i<j<k$ 都满足和为 $0$,因此答案为 $26235$。
Samples
Input #1
3
7 -4 -2
Output #1
1
Input #2
10
0 0 0 0 0 0 0 0 0 0
Output #2
26235
API Response (JSON)
{
  "problem": {
    "name": "[PA 2024] Bardzo Ulubiony Ciąg",
    "description": {
      "content": "**题目译自 [PA 2024](https://sio2.mimuw.edu.pl/c/pa-2024-1/dashboard/) Runda 5 [Bardzo Ulubiony Ciąg](https://sio2.mimuw.edu.pl/c/pa-2024-1/p/buc/),感谢 Macaronlin 提供翻译** 给定长度为 $n$ 的整数数组 $a$,$a$ 的所有子区间和形成长",
      "description_type": "Markdown"
    },
    "platform": "Luogu",
    "limit": {
      "time_limit": 3000,
      "memory_limit": 1048576
    },
    "difficulty": {
      "LuoguStyle": "P5"
    },
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "LGP10366"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "**题目译自 [PA 2024](https://sio2.mimuw.edu.pl/c/pa-2024-1/dashboard/) Runda 5 [Bardzo Ulubiony Ciąg](https://sio2.mimuw.edu.pl/c/pa-2024-1/p/buc/),感谢 Macaronlin 提供翻译**\n\n给定长度为 $n$ 的整数数组 $a$,$a$ 的所有子区间和形成长...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments