欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1877A.Goals of Victory
Goals of Victory
There are 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 teams . What is the efficiency of the missing team? It can be shown that the efficiency of the missing team can be uniquely determined.
Input
Each test contains multiple test cases. The first line contains an integer () — the number of test cases. The following lines contain the description of each test case.
The first line contains a single integer () — the number of teams.
The second line contains integers () — the efficiency of teams.
Output
For each test case, output a line containing an integer representing the efficiency of the missing team.
Note
In the first test case, below is a possible tournament result:
- Team vs. Team :
- Team vs. Team :
- Team vs. Team :
- Team vs. Team :
- Team vs. Team :
- Team vs. Team :
The efficiency of each team is:
- Team :
- Team :
- Team :
- Team :
Therefore, the efficiency of the missing team (team ) is .
It can be shown that any possible tournament of teams that has the efficiency of teams be , , and will always have the efficiency of the -th team be .
Samples
2
4
3 -4 5
11
-30 12 -57 7 0 -81 -68 41 -89 0
-4
265
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |