TopCoder

FHVirus
想像不出自己 AC 的題目是實作不出來的!

User's AC Ratio

85.1% (86/101)

Submission's AC Ratio

24.3% (153/629)

Tags

Description

給你一個圖(graph)上每個頂點(vertex)的度數(degree),請問這個圖是否可以是一個簡單無向圖(simple undirected graph)?

所謂的簡單圖,就是不包含重邊(multiple edge)、迴路(self cycle)的圖。
Graph

Input Format

輸入可能包含多筆測試資料。
每筆測試資料的第一列有一個正整數n(1<=n<=10,000),代表該圖的頂點數。
接下來有n個整數,代表每個點的度數(degree)(0<=degree<=10,000)。
當n=0時代表輸入結束。

Output Format

若可以建構出簡單無向圖,請輸出Yes,否則輸出No。

Sample Input 1

3
2 2 2
3
2 1 0
0

Sample Output 1

Yes
No

Hints

Problem Source

原TIOJ1210 / TIOJ 2008例行賽03 (prob B)。經典問題練習。Problem Setter:Tmt。

Subtasks

No. Testdata Range Score
1 0 25
2 1 25
3 2 25
4 3 25

Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 10000 65536 262144 1
1 10000 65536 262144 2
2 10000 65536 262144 3
3 10000 65536 262144 4