第 473 场 AtCoder Beginner Contest
B
抽鬼牌
Old Maid
AtCoder
⌀ 0
原题
← AD →

抽鬼牌AI (CI翻译)

Problem Statement

题目描述

AI (CI翻译)

Takahashi currently has $N$ cards. The $i$-th $(1\le i\le N)$ card has the integer $A _ i$ written on it.

Takahashi 目前有 $N$ 张卡片。第 $i$ 张 $(1\le i\le N)$ 卡片上写着整数 $A _ i$。AI (CI翻译)

He repeats the following operation as many times as possible.

他不断重复以下操作,直到无法继续操作为止。AI (CI翻译)

  • Choose two different cards with the same integer written on them, and eat those two cards. The eaten cards are permanently removed and cannot be chosen in subsequent operations.
  • 选择两张不同的、写有相同整数的卡片,并吃掉这两张卡片。被吃掉的卡片会被永久移除,无法在之后的操作中被选择。
AI (CI翻译)

Find the sum of the integers written on the cards that remain when the operation can no longer be performed.

求无法继续操作时,剩余卡片上所写整数的总和。AI (CI翻译)

Constraints

约束条件

AI (CI翻译)
  • $1\le N\le100$
  • $1\le A _ i\le100\ (1\le i\le N)$
  • All input values are integers.
  • $1\le N\le100$
  • $1\le A _ i\le100\ (1\le i\le N)$
  • 所有输入值均为整数。
AI (CI翻译)

Input

输入格式

AI (CI翻译)

The input is given from Standard Input in the following format:

输入通过标准输入给出,格式如下:AI (CI翻译)

N
A _ 1 A _ 2 \cdots A _ N

N
A _ 1 A _ 2 \cdots A _ N
AI (CI翻译)

Output

输出格式

AI (CI翻译)

Output the sum of the integers written on the remaining cards.

输出剩余卡片上所写整数的总和。AI (CI翻译)

样例

Input #1
8
2 7 1 8 2 8 1 8
Output #1
15
For example, Takahashi operates as follows. 1. The fourth card and sixth card both have $8$ written on them, so he chooses them and eats them. 2. The first card and fifth card both have $2$ written on them, so he chooses them and eats them. 3. The third card and seventh card both have $1$ written on them, so he chooses them and eats them. ![image](https://img.atcoder.jp/abc473/839dc9d3f8c77f88619fee1b74e6428d.png) Thus, the sum of the integers written on the remaining cards is $7+8=15$. Note that there are three cards with $8$ written on them, so once two of them are eaten, the remaining one cannot be eaten.
Input #2
5
1 2 3 4 5
Output #2
15
It is possible that Takahashi cannot perform the operation even once.
Input #3
15
58 97 74 16 97 74 97 16 51 52 58 52 74 32 43
Output #3
297
题目信息
题号
abc473_b
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。