A. Equator
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

Polycarp has created his own training plan to prepare for the programming contests. He will train for nn days, all days are numbered from 11to nn, beginning from the first.

On the ii-th day Polycarp will necessarily solve aiai problems. One evening Polycarp plans to celebrate the equator. He will celebrate it on the first evening of such a day that from the beginning of the training and to this day inclusive he will solve half or more of all the problems.

Determine the index of day when Polycarp will celebrate the equator.

Input

The first line contains a single integer nn (1≤n≤2000001≤n≤200000) — the number of days to prepare for the programming contests.

The second line contains a sequence a1,a2,…,ana1,a2,…,an (1≤ai≤100001≤ai≤10000), where aiai equals to the number of problems, which Polycarp will solve on the ii-th day.

Output

Print the index of the day when Polycarp will celebrate the equator.

Examples
input

Copy
4
1 3 2 1
output

Copy
2
input

Copy
6
2 2 2 2 2 2
output

Copy
3
Note

In the first example Polycarp will celebrate the equator on the evening of the second day, because up to this day (inclusive) he will solve 44out of 77 scheduled problems on four days of the training.

In the second example Polycarp will celebrate the equator on the evening of the third day, because up to this day (inclusive) he will solve 66out of 1212 scheduled problems on six days of the training.

 题意:求一组数据中大于等于和的一半的数的位置在哪

tips:一开始我用的是找的 t>sum/2的位置,然后被hack了,冷静分析了一波

如果输入的数据是      6     1 2 3 1 2 4时

得到的答案是 

但是实际上应该是4,因为 ‘/’ 这个是向0取整,所sum/2=6,但是在i=3这个地方时 t=6,所以为了‘/’所产生的误差 就用t*2>sum来判断 就不会产生误差

实际上是一个水题,但是要注意细节

附上代码

#include<bits/stdc++.h>
using namespace std;
const int maxx=;
typedef long long ll;
int a[maxx];
int main()
{
int n;
ll s=;
scanf("%d",&n);
for(int i=;i<=n;i++){
scanf("%d",&a[i]);
s+=a[i];
}
ll t=;
for(int i=;i<=n;i++){
t+=a[i];
if(t*>=s){
printf("%d\n",i);
break;
}
}
return ;
}

最新文章

  1. 移动端web开发,click touch tap区别
  2. [转]java selenium webdriver实战 应用小结
  3. ArcGIS Server开发教程系列(8)ArcGIS API for Javascript-控件(小部件)
  4. VIM编辑新文件自动添加头文件信息
  5. 研究dotnet动态语言IronPython(对应Java的Groovy)
  6. 关于SQL查询效率,100w数据,查询只要1秒
  7. To follow the path
  8. apk反编译(2)smali语言及文件
  9. VCL+FMX 双剑合壁编程
  10. 同步异步GET和POST请求
  11. java 协调同步的线程
  12. 浏览器中的user-agent的几种模式
  13. 015模块&mdash;&mdash;起别名
  14. 利用 UDF 轻松迁移
  15. eclipse无法添加tomcat
  16. centos 6 秘钥分发
  17. 黄聪: bootstrap 多模态框实现
  18. EBS 多sheet页Excel动态报表开发过程
  19. 关于Jmeter3.0,你必须要知道的5点变化
  20. mysql覆盖索引

热门文章

  1. python json.dumps raise TypeError(repr(o) + &quot; is not JSON serializable&quot;) TypeError: 0 is not JSON serializable
  2. 千锋教育Vue组件--vue基础的方法
  3. MPP(大规模并行处理)
  4. Git 基本命令与服务器搭建
  5. Small Talk Matters【闲谈很重要】
  6. C语言真正的编译过程(4个步骤~~预编译,编译,汇编,连接)
  7. 猜数字问题 python
  8. acm总结
  9. 17-比赛1 F - 较小元素 Weak in the Middle (set)
  10. 3226: [Sdoi2008]校门外的区间