#P3154. [CQOI2009] 循环赛

    ID: 2204 远端评测题 800ms 125MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>搜索2009重庆各省省选剪枝前缀和

[CQOI2009] 循环赛

Description

nn teams play a round-robin: every pair of teams plays exactly once, and a draw gives 11, a win 33, and a loss 00 points.

Given the teams’ final scores, find how many possible scoreboards there are.

平1胜3负0 means:

  • If two teams draw, each receives 11 point.
  • Otherwise, the winner receives 33 points, and the defeated team receives 00 points.

Input Format

The first line contains a positive integer nn, the number of teams. The second line contains nn non-negative integers, the score of each team.

Output Format

Output a single line: the number of possible scoreboards. It is guaranteed that at least one possible scoreboard exists.

6
5 6 7 7 8 8
121

Hint

All testdata satisfy n8n \le 8.

Translated by ChatGPT 5