Codeforces Round #356 (Div. 2)B. Bear and Finding Criminals(水题)

时间:2021-05-16 01:03:06
B. Bear and Finding Criminals
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

There are n cities in Bearland, numbered 1 through n. Cities are arranged in one long row. The distance between cities i and j is equal to |i - j|.

Limak is a police officer. He lives in a city a. His job is to catch criminals. It's hard because he doesn't know in which cities criminals are. Though, he knows that there is at most one criminal in each city.

Limak is going to use a BCD (Bear Criminal Detector). The BCD will tell Limak how many criminals there are for every distance from a citya. After that, Limak can catch a criminal in each city for which he is sure that there must be a criminal.

You know in which cities criminals are. Count the number of criminals Limak will catch, after he uses the BCD.

Input

The first line of the input contains two integers n and a (1 ≤ a ≤ n ≤ 100) — the number of cities and the index of city where Limak lives.

The second line contains n integers t1, t2, ..., tn (0 ≤ ti ≤ 1). There are ti criminals in the i-th city.

Output

Print the number of criminals Limak will catch.

Examples
input
6 3
1 1 1 0 1 0
output
3
input
5 2
0 0 0 1 0
output
1

链接:http://codeforces.com/contest/680/problem/B这题也是水题,直接看底下的NOTE,更容易懂。
#include<bits/stdc++.h>

using namespace std;

#define SI(N) scanf("%d",&(N))

int main()
{
int a[]={};
int n,in;
cin>>n>>in;
for (int i=;i<=n;i++)
{
SI(a[i]);
}
int ans=;
int l=in-,r=in+;
while(l>=&&r<=n)
{
if (a[l]==&&a[r]==)
{
ans+=;
}
l--,r++;
}
if (l==)
{
for (int i=r;i<=n;i++)
{
if (a[i]==)
ans++;
}
}
if (r==n+)
{
for (int i=l;i>=;i--)
{
if (a[i]==)
ans++;
}
}
if (a[in]==)
ans++;
printf("%d\n",ans);
return ;
}

Codeforces Round #356 (Div. 2)B. Bear and Finding Criminals(水题)的更多相关文章

  1. Codeforces Round &num;356 &lpar;Div&period; 2&rpar; B&period; Bear and Finding Criminal 水题

    B. Bear and Finding Criminals 题目连接: http://www.codeforces.com/contest/680/problem/B Description Ther ...

  2. Codeforces Round &num;356 &lpar;Div&period; 2&rpar; C&period; Bear and Prime 100 水题

    C. Bear and Prime 100 题目连接: http://www.codeforces.com/contest/680/problem/C Description This is an i ...

  3. Codeforces Round &num;356 &lpar;Div&period; 2&rpar; A&period; Bear and Five Cards 水题

    A. Bear and Five Cards 题目连接: http://www.codeforces.com/contest/680/problem/A Description A little be ...

  4. Codeforces Round &num;368 &lpar;Div&period; 2&rpar; A&period; Brain&&num;39&semi;s Photos (水题)

    Brain's Photos 题目链接: http://codeforces.com/contest/707/problem/A Description Small, but very brave, ...

  5. codeforces 680B B&period; Bear and Finding Criminals&lpar;水题&rpar;

    题目链接: B. Bear and Finding Criminals //#include <bits/stdc++.h> #include <vector> #includ ...

  6. Codeforces Round &num;356 &lpar;Div&period; 2&rpar; C&period; Bear and Prime 100(转)

    C. Bear and Prime 100 time limit per test 1 second memory limit per test 256 megabytes input standar ...

  7. Codeforces Round &num;373 &lpar;Div&period; 2&rpar; C&period; Efim and Strange Grade 水题

    C. Efim and Strange Grade 题目连接: http://codeforces.com/contest/719/problem/C Description Efim just re ...

  8. Codeforces Round &num;185 &lpar;Div&period; 2&rpar; A&period; Whose sentence is it&quest; 水题

    A. Whose sentence is it? Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/ ...

  9. Codeforces Round &num;373 &lpar;Div&period; 2&rpar; A&period; Vitya in the Countryside 水题

    A. Vitya in the Countryside 题目连接: http://codeforces.com/contest/719/problem/A Description Every summ ...

随机推荐

  1. Christmas Trees&comma; Promises和Event Emitters

    今天有同事问我下面这段代码是什么意思: var MyClass = function() { events.EventEmitter.call(this); // 这行是什么意思? }; util.i ...

  2. 【bzoj1455】罗马游戏 可并堆

    2016-05-31  10:04:41 可并堆的裸题. 左偏树(小根堆为例 性质 1.满足堆的性质,每个节点权值小于左右儿子权值 2.每个节点有dis值,表示子树最浅的叶子深度加1 3.左子树dis ...

  3. Genymotion模拟器环境搭建中的各种坑,终极解决办法

    最近刚进入了一家公司,因为要做自动化测试,web端的业务需要移动端来进行配合,想了想还是利用genymotion模拟器吧:很久前装过,那也是一路坎坷啊,结果这次还是遇到坑了,搞了老半天:我希望我踩过的 ...

  4. 李洪强iOS开发之OC面向对象—多态

    OC面向对象—多态 一.基本概念 多态在代码中的体现,即为多种形态,必须要有继承,没有继承就没有多态. 在使用多态是,会进行动态检测,以调用真实的对象方法. 多态在代码中的体现即父类指针指向子类对象. ...

  5. &lbrack;Swift&rsqb;LeetCode55&period; 跳跃游戏 &vert; Jump Game

    Given an array of non-negative integers, you are initially positioned at the first index of the arra ...

  6. 散度、旋度与 Laplacian

    $$\bex -\lap {\bf u}=\rot \rot {\bf u}-\n \Div {\bf u}. \eex$$

  7. vue 路由配置

    1.不带参数的路由配置 及 跳转 //路由配置: { name: "a", path: "/a", component: a }   页面跳转: this.$r ...

  8. java中出现内存溢出的几种情况

    情况一:java.lang.OutOfMemoryError: Java heap space 原因:java堆内存不足,可能是真的不足,也可能是程序中有死循环 方案:1.调整JVM参数-Xms204 ...

  9. php正则替换函数-----preg&lowbar;replace &lpar; mixed &dollar;pattern &comma; mixed &dollar;replacement &comma; mixed &dollar;subject &lbrack;&comma; int &dollar;limit &equals; -1 &lbrack;&comma; int &amp&semi;&dollar;count &rsqb;&rsqb; &rpar;

    preg_replace — 执行一个正则表达式的搜索和替换 说明 mixed preg_replace ( mixed $pattern , mixed $replacement , mixed $ ...

  10. &lbrack;HTML&sol;CSS&rsqb;有一种节点叫做文本节点

    HTML可以看成是由节点(node)组成的树结构 我们一般都是在<p>节点里面写字符串. 在上图中,<p>节点和字符串之间有一个text, 这个text就是文本节点. 我们可以 ...