304691: CF895A. Pizza Separation
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Pizza Separation
题意翻译
### 题目描述 一个圆,被切成了 $n$ 块,第 $i$ 块的圆心角为 $a_i$。 你可以将相邻的块合并,直到这 $n$ 块组合成两大块,你需要使得这两大块的圆心角之差最小。 ### 输入格式 第一行包括一个整数 $n$,表示圆被分成的块数。 第二行包括 $n$ 个整数 $a_i$,表示第 $i$ 块的圆心角度数。 ### 输出格式 一个整数,表示最小的圆心角之差。 ### 说明/提示 对于 $100\%$ 的数据,$1\le n, a_i\le 360$。 数据保证所有圆心角度数之和为 $360$ 度。 样例一说明:第 $1$ 块和第 $2$ 块组成一块,第 $3$ 块和第 $4$ 块组成一块,答案即为 $[(90 + 90) - (90 + 90)] = 0$。 样例二说明:第 $1$ 块和第 $2$ 块组成一块,第 $3$ 块单独组成一块,答案即为 $[(100 + 100) - 160] = 40$。 样例三说明:一共只有 $1$ 块披萨,只能被一个人拿走,答案即为 $(360 - 0) = 360$。 样例四说明:第 $1$ 块和第 $4$ 块组成一块,第 $2$ 块和第 $3$ 块组成一块,答案即为 $[(170 + 10) - (30 + 150)] = 0$。题目描述
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.输入输出格式
输入格式
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.
输出格式
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