logo AlgoBeat OnlineJudge
登录 注册

#214932. [ICPC 2022 Yokohama R] Make a Loop

内存限制:1024 MiB 时间限制:2000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

Taro is playing with a set of toy rail tracks. All of the tracks are arc-shaped with a right central angle (an angle of degrees), but with many different radii. He is trying to construct a single loop using all of them. Here, a set of tracks is said to form a single loop when both ends of all the tracks are smoothly joined to some other track, and all the tracks are connected to all the other tracks directly or indirectly. Please tell Taro whether he can ever achieve that or not.

Tracks may be joined in an arbitrary order, but their directions are restricted by the directions of adjacent tracks, as they must be joined smoothly. For example, if you place a track so that a train enters eastward and turns degrees northward, you must place the next track so that the train enters northward and turns degrees to either east or west (Figure F.1). Tracks may cross or even overlap each other as elevated construction is possible.

:::align{center}

Figure F.1. Example of smoothly joining tracks :::

输入格式

The input consists of a single test case in the following format.

represents the number of tracks, which is an even integer satisfying . Each represents the radius of the -th track, which is an integer satisfying .

输出格式

If it is possible to construct a single loop using all of the tracks, print Yes; otherwise, print No.

样例

样例输入 1

4
1 1 1 1

样例输出 1

Yes

样例输入 2

6
1 3 1 3 1 3

样例输出 2

Yes

样例输入 3

6
2 2 1 1 1 1

样例输出 3

No

样例输入 4

8
99 98 15 10 10 5 2 1

样例输出 4

Yes

数据范围与提示

Possible loops for the sample inputs 1, 2, and 4 are depicted in the following figures.

:::align{center} Figure F.2. Possible loops for the sample inputs :::