A. ACM ICPC

Codeforces
IDCF886A
Time2000ms
Memory256MB
Difficulty
brute force
English · Original
Chinese · Translation
Formal · Original
In a small but very proud high school it was decided to win ACM ICPC. This goal requires to compose as many teams of three as possible, but since there were only 6 students who wished to participate, the decision was to build exactly two teams. After practice competition, participant number _i_ got a _score_ of _a__i_. _Team score_ is defined as sum of scores of its participants. High school management is interested if it's possible to build two teams with equal scores. Your task is to answer that question. ## Input The single line contains six integers _a_1, ..., _a_6 (0 ≤ _a__i_ ≤ 1000) — scores of the participants ## Output Print "_YES_" (quotes for clarity), if it is possible to build teams with equal score, and "_NO_" otherwise. You can print each character either upper- or lowercase ("_YeS_" and "_yes_" are valid when the answer is "_YES_"). [samples] ## Note In the first sample, first team can be composed of 1st, 2nd and 6th participant, second — of 3rd, 4th and 5th: team scores are 1 + 3 + 1 = 2 + 1 + 2 = 5. In the second sample, score of participant number 6 is too high: his team score will be definitely greater.
在一所小但非常自豪的高中,决定赢得 ACM ICPC。实现这一目标需要尽可能多地组成三人团队,但由于只有 #cf_span[6] 名学生希望参赛,因此决定恰好组成两个团队。 在一次练习赛之后,第 #cf_span[i] 名参与者获得了 _分数_ #cf_span[ai]。_团队分数_ 定义为其成员分数之和。学校管理层想知道是否有可能组成两个分数相等的团队。你的任务是回答这个问题。 单行包含六个整数 #cf_span[a1, ..., a6] (#cf_span[0 ≤ ai ≤ 1000]) —— 参与者的分数。 如果可以组成两个分数相等的团队,则输出 "_YES_"(引号用于清晰),否则输出 "_NO_"。 你可以以任意大小写形式打印每个字符(当答案为 "_YES_" 时,"_YeS_" 和 "_yes_" 均为有效)。 在第一个样例中,第一个团队可以由第 #cf_span[1] 名、第 #cf_span[2] 名和第 #cf_span[6] 名参与者组成,第二个团队由第 #cf_span[3] 名、第 #cf_span[4] 名和第 #cf_span[5] 名参与者组成:团队分数为 #cf_span[1 + 3 + 1 = 2 + 1 + 2 = 5]。 在第二个样例中,第 #cf_span[6] 名参与者的分数过高:其所在团队的分数必然更大。 ## Input 单行包含六个整数 #cf_span[a1, ..., a6] (#cf_span[0 ≤ ai ≤ 1000]) —— 参与者的分数 ## Output 如果可以组成两个分数相等的团队,则输出 "_YES_"(引号用于清晰),否则输出 "_NO_"。你可以以任意大小写形式打印每个字符(当答案为 "_YES_" 时,"_YeS_" 和 "_yes_" 均为有效)。 [samples] ## Note 在第一个样例中,第一个团队可以由第 #cf_span[1] 名、第 #cf_span[2] 名和第 #cf_span[6] 名参与者组成,第二个团队由第 #cf_span[3] 名、第 #cf_span[4] 名和第 #cf_span[5] 名参与者组成:团队分数为 #cf_span[1 + 3 + 1 = 2 + 1 + 2 = 5]。在第二个样例中,第 #cf_span[6] 名参与者的分数过高:其所在团队的分数必然更大。
Let $ a_1, a_2, a_3, a_4, a_5, a_6 \in \mathbb{Z}_{\geq 0} $ be the scores of the six participants. Let $ S = \sum_{i=1}^{6} a_i $ be the total sum of all scores. It is possible to partition the six participants into two disjoint teams of three participants each, such that both teams have equal score, **if and only if**: - $ S $ is even, and - there exists a subset $ T \subseteq \{a_1, a_2, a_3, a_4, a_5, a_6\} $ with $ |T| = 3 $ such that $ \sum_{x \in T} x = \frac{S}{2} $. **Objective:** Determine whether such a subset $ T $ exists. Output "YES" if such a partition exists; otherwise, output "NO".
Samples
Input #1
1 3 2 1 2 1
Output #1
YES
Input #2
1 1 1 1 1 99
Output #2
NO
API Response (JSON)
{
  "problem": {
    "name": "A. ACM ICPC",
    "description": {
      "content": "In a small but very proud high school it was decided to win ACM ICPC. This goal requires to compose as many teams of three as possible, but since there were only 6 students who wished to participate, ",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF886A"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "In a small but very proud high school it was decided to win ACM ICPC. This goal requires to compose as many teams of three as possible, but since there were only 6 students who wished to participate, ...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "在一所小但非常自豪的高中,决定赢得 ACM ICPC。实现这一目标需要尽可能多地组成三人团队,但由于只有 #cf_span[6] 名学生希望参赛,因此决定恰好组成两个团队。\n\n在一次练习赛之后,第 #cf_span[i] 名参与者获得了 _分数_ #cf_span[ai]。_团队分数_ 定义为其成员分数之和。学校管理层想知道是否有可能组成两个分数相等的团队。你的任务是回答这个问题。\n\n单行包含六个...",
      "is_translate": true,
      "language": "Chinese"
    },
    {
      "statement_type": "Markdown",
      "content": "Let $ a_1, a_2, a_3, a_4, a_5, a_6 \\in \\mathbb{Z}_{\\geq 0} $ be the scores of the six participants.\n\nLet $ S = \\sum_{i=1}^{6} a_i $ be the total sum of all scores.\n\nIt is possible to partition the six...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments