codeforce 962A Equator

原创 2018年04月16日 21:29:31

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 (1n2000001≤n≤200000) — the number of days to prepare for the programming contests.

The second line contains a sequence a1,a2,,ana1,a2,…,an (1ai100001≤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.


注意结果的奇偶即可;

下面附上我的代码:

#include<bits/stdc++.h>
using namespace std;
typedef long long LL; 
const int MAXN = 2e5 + 5;
int a[MAXN];
LL sum[MAXN];
int main()
{
	int n;
	LL sum1 = 0;
	cin>>n;
	for(int i = 1; i <= n; i++)
	{
		scanf("%d",&a[i]);
		sum[i] = sum[i-1] + a[i];
		sum1 += a[i];
	}
	int u = -1;
	if(sum1 & 1)
		sum1++;
	for(int i = 1; i <= n; i++)
		if(sum[i] >= sum1 / 2)
		{
			u = i;
			break;	
		}
	printf("%d\n",u);
	return 0;
}


版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/gtuif/article/details/79966921

Educational Codeforces Round 42(4.11)

A. Equator Polycarp has created his own training plan to prepare for the programming contests. He w...
  • qq_38200023
  • qq_38200023
  • 2018-04-11 18:58:53
  • 55

codeforce 962A Equator

A. Equatortime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputsta...
  • gtuif
  • gtuif
  • 2018-04-16 21:29:31
  • 19

Educational Codeforces Round 42 (Rated for Div. 2) A. Equator

A. Equatortime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputst...
  • Eric_chen_song_lin
  • Eric_chen_song_lin
  • 2018-04-12 14:59:26
  • 58

cf_159C. String Manipulation线段树+字符串

C. String Manipulation 1.0 time limit per test 3 seconds memory limit per test 256 megab...
  • u014794992
  • u014794992
  • 2014-10-09 20:34:28
  • 265

cf. Polycarpus' Dice

题目链接;http://codeforces.com/problemset/problem/534/C 这题主要是A,s会越界,导致一直在wa,目测wa了5次,终于AC! 题目: ...
  • GrEedWish_X
  • GrEedWish_X
  • 2015-04-22 08:07:13
  • 283

【CodeForces 159C】String Manipulation 1.0(字符串处理)

 C. String Manipulation 1.0 time limit per test 3 seconds memory limit per test 256 m...
  • fsmm_blog
  • fsmm_blog
  • 2017-03-22 11:54:23
  • 203

你所不知道的Oracle后台进程SMON功能

原帖地址:点击打开链接 SMON(system monitor process)系统监控后台进程,有时候也被叫做system cleanup process,这么叫的原因是它负责完成很多清理...
  • chacheen
  • chacheen
  • 2013-10-27 00:03:16
  • 4558

[CF 249D]Donkey and Start解题报告

题意 第一象限上有n 像这样: 它的坐标是x轴往左,y轴往上……我估计这么做的原因是为了迷惑你…… 分析 这道题的关键是很明显的:假设过原点,斜率为k...
  • wmdcstdio
  • wmdcstdio
  • 2015-06-26 11:59:25
  • 599

CF534

终于写了一篇div2的题解..我还是很弱 A. Exam     题意就是构造一个排列使得相邻两项的差值大于1。     n     n >= 4 的情况可以按如下的方式构造     ...
  • u011572615
  • u011572615
  • 2015-04-13 03:26:29
  • 260

高通 SDM450插入充电器开机log

Format: Log Type - Time(microsec) - Message - Optional Info Log Type: B - Since Boot(Power On Reset...
  • yuewen2008
  • yuewen2008
  • 2017-07-13 13:06:06
  • 3421
收藏助手
不良信息举报
您举报文章:codeforce 962A Equator
举报原因:
原因补充:

(最多只允许输入30个字)