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 ;
}

Educational Codeforces Round 42 (Rated for Div. 2) A的更多相关文章

  1. Educational Codeforces Round 42 (Rated for Div. 2) E. Byteland, Berland and Disputed Cities

    http://codeforces.com/contest/962/problem/E E. Byteland, Berland and Disputed Cities time limit per ...

  2. Educational Codeforces Round 42 (Rated for Div. 2) D. Merge Equals

    http://codeforces.com/contest/962/problem/D D. Merge Equals time limit per test 2 seconds memory lim ...

  3. Educational Codeforces Round 42 (Rated for Div. 2)F - Simple Cycles Edges

    http://codeforces.com/contest/962/problem/F 求没有被两个及以上的简单环包含的边 解法:双联通求割顶,在bcc中看这是不是一个简单环,是的话把整个bcc的环加 ...

  4. Educational Codeforces Round 42 (Rated for Div. 2) C

    C. Make a Square time limit per test 2 seconds memory limit per test 256 megabytes input standard in ...

  5. Educational Codeforces Round 42 (Rated for Div. 2) B

    B. Students in Railway Carriage time limit per test 2 seconds memory limit per test 256 megabytes in ...

  6. D. Merge Equals(from Educational Codeforces Round 42 (Rated for Div. 2))

    模拟题,运用强大的stl. #include <iostream> #include <map> #include <algorithm> #include < ...

  7. Educational Codeforces Round 42 (Rated for Div. 2)

    A. Equator(模拟) 找权值的中位数,直接模拟.. 代码写的好丑qwq.. #include<cstdio> #include<cstring> #include< ...

  8. C Make a Square Educational Codeforces Round 42 (Rated for Div. 2) (暴力枚举,字符串匹配)

    C. Make a Square time limit per test2 seconds memory limit per test256 megabytes inputstandard input ...

  9. D Merge Equals Educational Codeforces Round 42 (Rated for Div. 2) (STL )

    D. Merge Equals time limit per test2 seconds memory limit per test256 megabytes inputstandard input ...

随机推荐

  1. eclipse引入jquery文件报错解决

    以下内容是小编给大家带来的关于Eclipse引入jquery报错如何解决的全部叙述,具体内容如下所示: 第一步: 去除eclipse的JS验证: 将windows->preference-> ...

  2. thinkPHP5.0 save和saveAll,新增和更新的问题

    今天遇到一个问题,在模型中使用save保存数据之后,使用saveAll继续新增数据,结果报 缺少更新条件,网上搜了下发现一篇文章https://www.jianshu.com/p/1848f61de6 ...

  3. Python常用函数记录

    Python常用函数/方法记录 一. Python的random模块: 导入模块: import random 1. random()方法: 如上如可知该函数返回一个[0,1)(左闭右开)的一个随机的 ...

  4. win8电脑字体出现方格的解决方法

    一般电脑出现乱码有几种可能,最常见的可能就是电脑字体的丢失,其次就是电脑字体被病毒所损坏,因此,首先我们要做的就是下载字体并进行安装. 下载 simsun.tcc点击安装,如果电脑字体依然是这种情况( ...

  5. C++基础 const

    1. C中的const C中const变量只是只读变量,有自己存储空间.可能被存放在 栈.堆.数据段,所以可以修改. 2. C++中const 可能分配空间,也可能不分配空间. 当 const 为全局 ...

  6. [WC2002][洛谷P1578]奶牛浴场

    洛谷题解里那个人可真是话多呢. 题目描述 由于John建造了牛场围栏,激起了奶牛的愤怒,奶牛的产奶量急剧减少.为了讨好奶牛,John决定在牛场中建造一个大型浴场.但是John的奶牛有一个奇怪的习惯,每 ...

  7. DJango跨域中间键

    Skip to main content   Search PyPISearch Help Donate Log in Register django-cors-middleware 1.3.1 pi ...

  8. 通过广播关闭应用程序(每个Activity)和连续点击两次返回键关闭应用程序

    对于一个应用程序可能有很多个Activity,可能每个人并不想一个个的去关闭Activity,也有可能忘了,那怎么关闭所有的未关闭的Activity呢,其实有很多方法,但是我最喜欢的一种就是通过广播事 ...

  9. python学习笔记十一:操作mysql

    一.安装MySQL-python # yum install -y MySQL-python 二.打开数据库连接 #!/usr/bin/python import MySQLdb conn = MyS ...

  10. U盘的容量变小了怎么办?

    之前买了个U盘,后来给朋友装系统弄成U盘启动盘了,就发现U盘容量变少了几百兆,原来是因为做U盘启动盘的时候,U盘启动盘制作软件都是把写入U盘的PE文件隐藏了,防止用户不小心删除文件. 所以说这些空间应 ...