一种枚举指定序列的方法 ————CF A. Pizza Separation
来源:互联网 发布:c语言flag程序 编辑:程序博客网 时间:2024/05/05 07:46
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 ai. 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 ai (1 ≤ ai ≤ 360) — the angles of the sectors into which the pizza was cut. The sum of all ai is 360.
Print one integer — the minimal difference between angles of sectors that will go to Vasya and Petya.
490 90 90 90
0
3100 100 160
40
1360
360
4170 30 150 10
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.
———————————————————————————————————————————————————————————
题目的意思是给你一个序列找出一个区间是的它的和与剩下的所有数的和差值最小,求
差值
思路:暴力枚举所有情况
- 一种枚举指定序列的方法 ————CF A. Pizza Separation
- CF-448(Div.2)-A. Pizza Separation
- codeforces A. Pizza Separation
- A. Pizza Separation
- #448 div2 a Pizza Separation
- D—separation
- codeforces #448(div 2) A. Pizza Separation
- Codeforces Round #448 (Div. 2) A. Pizza Separation 前缀和
- Codeforces Round #448 (Div. 2) A. Pizza Separation
- Codeforces Round #448 (Div. 2) 895A. Pizza Separation
- Codeforces895A. Pizza Separation
- Pizza Separation CodeForces
- cf——#30A
- 未知:天上掉pizza——题解
- 用递归方法实现指定目录的枚举——兼谈File类的使用
- cfA. Pizza Separation(前缀和)
- CF——#142div2 C(暴力枚举)
- 枚举服务的一种方法
- 习题2-4子序列的和
- AFIO时钟
- Django框架全面讲解 -- Django 路由系统
- 初识SQL
- git 中的 tag 常规使用
- 一种枚举指定序列的方法 ————CF A. Pizza Separation
- 02-eclipse中使用git
- c++初级 之 vector与list对比
- JavaEE_领域模型命名规约 与 dozer 的简单使用介绍
- Php连接及读取和写入mysql数据库的常用代码
- spring3笔记2-IOC
- 8根网线的作用及接法
- linux 下安装redis
- Java获取请求客户端的真实IP地址