CF895A.Pizza Separation
普及-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Students Vasya and Petya are studying at the BSU (Byteland State University). At one of the breaks they decided to order a pizza. In this problem pizza is a circle of some radius. The pizza was delivered already cut into n pieces. The i-th piece is a sector of angle equal to a__i. Vasya and Petya want to divide all pieces of pizza into two continuous sectors in such way that the difference between angles of these sectors is minimal. Sector angle is sum of angles of all pieces in it. Pay attention, that one of sectors can be empty.
学生瓦夏和佩佳就读于BSU(比特兰国立大学)。在一次课间休息时,他们决定点一份披萨。本题中,披萨是一个半径为某值的圆。披萨送达时已被切成了 n 块。第 i 块是一个圆心角为 ai 的扇形。瓦夏和佩佳希望将所有披萨块分成两个连续的扇形区域,使得这两个扇形区域的圆心角之差最小。扇形区域的圆心角等于其中所含所有披萨块的圆心角之和。注意:其中一个扇形区域可以为空。
输入格式
The first line contains one integer n (1 ≤ n ≤ 360) — the number of pieces into which the delivered pizza was cut.
The second line contains n integers a__i (1 ≤ a__i ≤ 360) — the angles of the sectors into which the pizza was cut. The sum of all a__i is 360.
第一行包含一个整数 n(1≤n≤360)—— 表示送来的披萨被切分的块数。
第二行包含 n 个整数 ai(1≤ai≤360)—— 表示披萨被切分出的各扇形的角度。所有 ai 的总和为 360。
输出格式
Print one integer — the minimal difference between angles of sectors that will go to Vasya and Petya.
输出一个整数——分给瓦夏和佩佳的扇形区域角度之间的最小差值。
输入输出样例
输入#1
4 90 90 90 90
输出#1
0
输入#2
3 100 100 160
输出#2
40
输入#3
1 360
输出#3
360
输入#4
4 170 30 150 10
输出#4
0
说明/提示
In first sample Vasya can take 1 and 2 pieces, Petya can take 3 and 4 pieces. Then the answer is |(90 + 90) - (90 + 90)| = 0.
In third sample there is only one piece of pizza that can be taken by only one from Vasya and Petya. So the answer is |360 - 0| = 360.
In fourth sample Vasya can take 1 and 4 pieces, then Petya will take 2 and 3 pieces. So the answer is |(170 + 10) - (30 + 150)| = 0.
Picture explaning fourth sample:

Both red and green sectors consist of two adjacent pieces of pizza. So Vasya can take green sector, then Petya will take red sector.
在第一个样例中,瓦西娅可以取第 1 和第 2 块披萨,佩蒂亚可以取第 3 和第 4 块披萨。因此答案为 ∣(90 + 90) − (90 + 90)∣ = 0。
在第三个样例中,只有一块披萨,且只能由瓦西娅和佩蒂亚中的一人取走。因此答案为 ∣360 − 0∣ = 360。
在第四个样例中,瓦西娅可以取第 1 和第 4 块披萨,随后佩蒂亚将取第 2 和第 3 块披萨。因此答案为 ∣(170 + 10) − (30 + 150)∣ = 0。
解释第四个样例的示意图:

红色与绿色扇形区域均由两块相邻的披萨组成。因此瓦西娅可以取绿色扇形区域,随后佩蒂亚将取红色扇形区域。
输入解题思路,AI测评打分。不知道怎么写?