CF1877A.Goals of Victory

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

There are nn 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−1n-1 teams a1,a2,a3,…,an−1a_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.

一场足球锦标赛共有 nn 支队伍。每两支队伍之间恰好进行一场比赛。每场比赛结束后,Pak Chanek 会收到两个整数,分别表示两支参赛队伍在该场比赛中各自攻入的进球数。一支队伍的效率定义为:该队在所有比赛中进球总数,减去其所有对手在与该队比赛时的进球总数。

锦标赛结束后,Pak Dengklek 计算了每支队伍的效率。结果他发现,自己遗漏了其中一支队伍的效率值。现已知其余 n−1n-1 支队伍的效率分别为 a1,a2,a3,…,an−1a_1, a_2, a_3, \ldots, a_{n-1}。请问:被遗漏的那支队伍的效率是多少?可以证明,该缺失队伍的效率值是唯一确定的。

输入格式

Each test contains multiple test cases. The first line contains an integer tt (1≤t≤5001 \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 nn (2≤n≤1002 \leq n \leq 100) — the number of teams.

The second line contains n−1n-1 integers a1,a2,a3,…,an−1a_1,a_2,a_3,\ldots,a_{n-1} (−100≤ai≤100-100\leq a_i\leq100) — the efficiency of n−1n-1 teams.

每个测试包含多个测试用例。第一行包含一个整数 tt(1≤t≤5001 \leq t \leq 500),表示测试用例的数量。接下来的各行描述每个测试用例。

第一行包含一个整数 nn(2≤n≤1002 \leq n \leq 100),表示队伍的数量。

第二行包含 n−1n-1 个整数 a1,a2,a3,…,an−1a_1,a_2,a_3,\ldots,a_{n-1}(−100≤ai≤100-100\leq a_i\leq100),表示 n−1n-1 支队伍的效率。

输出格式

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 11 vs. Team 22: 1−21-2
  • Team 11 vs. Team 33: 3−03-0
  • Team 11 vs. Team 44: 3−23-2
  • Team 22 vs. Team 33: 1−41-4
  • Team 22 vs. Team 44: 1−31-3
  • Team 33 vs. Team 44: 5−05-0

The efficiency of each team is:

  1. Team 11: (1+3+3)−(2+0+2)=7−4=3(1+3+3)-(2+0+2)=7-4=3
  2. Team 22: (2+1+1)−(1+4+3)=4−8=−4(2+1+1)-(1+4+3)=4-8=-4
  3. Team 33: (0+4+5)−(3+1+0)=9−4=5(0+4+5)-(3+1+0)=9-4=5
  4. Team 44: (2+3+0)−(3+1+5)=5−9=−4(2+3+0)-(3+1+5)=5-9=-4

Therefore, the efficiency of the missing team (team 44) is −4-4.

It can be shown that any possible tournament of 44 teams that has the efficiency of 33 teams be 33, −4-4, and 55 will always have the efficiency of the 44-th team be −4-4.

在第一个测试用例中,以下是一种可能的锦标赛结果:

  • 球队 11 对阵 球队 22:11–22
  • 球队 11 对阵 球队 33:33–00
  • 球队 11 对阵 球队 44:33–22
  • 球队 22 对阵 球队 33:11–44
  • 球队 22 对阵 球队 44:11–33
  • 球队 33 对阵 球队 44:55–00

各球队的效率为:

  1. 球队 11:(1+3+3)−(2+0+2)=7−4=3(1+3+3)-(2+0+2)=7-4=3
  2. 球队 22:(2+1+1)−(1+4+3)=4−8=−4(2+1+1)-(1+4+3)=4-8=-4
  3. 球队 33:(0+4+5)−(3+1+0)=9−4=5(0+4+5)-(3+1+0)=9-4=5
  4. 球队 44:(2+3+0)−(3+1+5)=5−9=−4(2+3+0)-(3+1+5)=5-9=-4

因此,缺失球队(即球队 44)的效率为 −4-4。

可以证明:对于任意一场包含 44 支球队的锦标赛,若其中 33 支球队的效率分别为 33、−4-4 和 55,则第 44 支球队的效率恒为 −4-4。

输入解题思路,AI测评打分。不知道怎么写?

首页