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

时间:2023-01-30 12:05:57
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时

得到的答案是 Educational Codeforces Round 42 (Rated for Div. 2)  A

但是实际上应该是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 &lpar;Rated for Div&period; 2&rpar; E&period; Byteland&comma; 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 &lpar;Rated for Div&period; 2&rpar; D&period; 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 &lpar;Rated for Div&period; 2&rpar;F - Simple Cycles Edges

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

  4. Educational Codeforces Round 42 &lpar;Rated for Div&period; 2&rpar; 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 &lpar;Rated for Div&period; 2&rpar; B

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

  6. D&period; Merge Equals(from Educational Codeforces Round 42 &lpar;Rated for Div&period; 2&rpar;)

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

  7. Educational Codeforces Round 42 &lpar;Rated for Div&period; 2&rpar;

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

  8. C&Tab; Make a Square Educational Codeforces Round 42 &lpar;Rated for Div&period; 2&rpar; &lpar;暴力枚举,字符串匹配&rpar;

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

  9. D&Tab; Merge Equals Educational Codeforces Round 42 &lpar;Rated for Div&period; 2&rpar; (STL )

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

随机推荐

  1. Windows下80端口被pid为4的System进程占用解决方法

    前言 之前是Windows 7系统,前段时间装了Windows 10,php环境还没来得及搭建.今天折腾了一下,是用nginx+php,端口是80(已经停止了iis服务),nginx就是起不来,十之八 ...

  2. Java 测试代码模板

    package com.robert.service; import org.apache.commons.logging.Log; import org.apache.commons.logging ...

  3. java override

    java override // 覆盖父类的方法,在子类直接调用子类内部这个方法时 public class TestCalc{ protected static class Wine{ String ...

  4. Redirect 原理

    mvc .net 中,从服务器端跳转页面有很多方法 有些不会改变浏览器地址栏的地址,这个好理解,mvc本身的机制就是action的名字不一定是view的名字 我们请求的不是文件名,在action中我们 ...

  5. 图片延迟加载插件jquery&period;lazyload&period;js的使用方法

    最新版的jquery.lazyload.js已不再是伪的延迟加载了 一.请按照基本使用方法说明设置 //载入JavaScript 文件 <script src="jquery.js&q ...

  6. Docker 基础 &colon; 网络配置

    大量的互联网应用服务包含多个服务组件,这往往需要多个容器之间通过网络通信进行相互配合.Docker 目前提供了映射容器端口到宿主主机和容器互联机制来为容器提供网络服务.接下来我们将讲述 Docker ...

  7. JS:判断是否是移动端

    通过User-Agent判断 代码: if(navigator.userAgent.match(/mobile/i)) { //业务层代码 $('body').removeClass("si ...

  8. mysql 分组取最新的一条记录&lpar;整条记录&rpar;

    方法:mysql取分组后最新的一条记录,下面两种方法.一种是先筛选 出最大和最新的时间,在连表查询.一种是先排序,然后在次分组查询(默认第一条),就是最新的一条数据了  #select * from ...

  9. 用脚手架创建vue项目

    .创建文件地址 首先创建一个文件夹,我用的HBuilder编辑器 , 然后把文件夹拖入编辑器 , 在你创建的文件夹里面打开cmd 2.输入安装命令 : 1). npm install --global ...

  10. dubbo 学习(5) dubbo多协议和多注册中心

    转载 http://blog.csdn.net/songjinbin/article/details/49498431 一.配置dubbo多协议模式 1.默认协议 Dubbo缺省协议采用单一长连接和N ...