A16205 | Goals of Victory
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
There are $n$ teams in a football tournament. Each pair of teams match up once. After every match, Pak Chanek receives two integers as the result of the match, the number of goals the two teams score during the match. The efficiency of a team is equal to the total number of goals the team scores in each of its matches minus the total number of goals scored by the opponent in each of its matches.
After the tournament ends, Pak Dengklek counts the efficiency of every team. Turns out that he forgot about the efficiency of one of the teams. Given the efficiency of $n-1$ teams $a_1,a_2,a_3,\ldots,a_{n-1}$ . What is the efficiency of the missing team? It can be shown that the efficiency of the missing team can be uniquely determined.
After the tournament ends, Pak Dengklek counts the efficiency of every team. Turns out that he forgot about the efficiency of one of the teams. Given the efficiency of $n-1$ teams $a_1,a_2,a_3,\ldots,a_{n-1}$ . What is the efficiency of the missing team? It can be shown that the efficiency of the missing team can be uniquely determined.
输入格式
Each test contains multiple test cases. The first line contains an integer $t$ ( $1 \leq t \leq 500$ ) — the number of test cases. The following lines contain the description of each test case.
The first line contains a single integer $n$ ( $2 \leq n \leq 100$ ) — the number of teams.
The second line contains $n-1$ integers $a_1,a_2,a_3,\ldots,a_{n-1}$ ( $-100\leq a_i\leq100$ ) — the efficiency of $n-1$ teams.
The first line contains a single integer $n$ ( $2 \leq n \leq 100$ ) — the number of teams.
The second line contains $n-1$ integers $a_1,a_2,a_3,\ldots,a_{n-1}$ ( $-100\leq a_i\leq100$ ) — the efficiency of $n-1$ teams.
输出格式
For each test case, output a line containing an integer representing the efficiency of the missing team.
输入输出样例
输入 #1
2 4 3 -4 5 11 -30 12 -57 7 0 -81 -68 41 -89 0
输出 #1
-4 265
In the first test case, below is a possible tournament result:
- Team $1$ vs. Team $2$ : $1-2$
- Team $1$ vs. Team $3$ : $3-0$
- Team $1$ vs. Team $4$ : $3-2$
- Team $2$ vs. Team $3$ : $1-4$
- Team $2$ vs. Team $4$ : $1-3$
- Team $3$ vs. Team $4$ : $5-0$
The efficiency of each team is:
1. Team $1$ : $(1+3+3)-(2+0+2)=7-4=3$
2. Team $2$ : $(2+1+1)-(1+4+3)=4-8=-4$
3. Team $3$ : $(0+4+5)-(3+1+0)=9-4=5$
4. Team $4$ : $(2+3+0)-(3+1+5)=5-9=-4$
Therefore, the efficiency of the missing team (team $4$ ) is $-4$ .
It can be shown that any possible tournament of $4$ teams that has the efficiency of $3$ teams be $3$ , $-4$ , and $5$ will always have the efficiency of the $4$ -th team be $-4$ .
- Team $1$ vs. Team $2$ : $1-2$
- Team $1$ vs. Team $3$ : $3-0$
- Team $1$ vs. Team $4$ : $3-2$
- Team $2$ vs. Team $3$ : $1-4$
- Team $2$ vs. Team $4$ : $1-3$
- Team $3$ vs. Team $4$ : $5-0$
The efficiency of each team is:
1. Team $1$ : $(1+3+3)-(2+0+2)=7-4=3$
2. Team $2$ : $(2+1+1)-(1+4+3)=4-8=-4$
3. Team $3$ : $(0+4+5)-(3+1+0)=9-4=5$
4. Team $4$ : $(2+3+0)-(3+1+5)=5-9=-4$
Therefore, the efficiency of the missing team (team $4$ ) is $-4$ .
It can be shown that any possible tournament of $4$ teams that has the efficiency of $3$ teams be $3$ , $-4$ , and $5$ will always have the efficiency of the $4$ -th team be $-4$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted