题库练习 Bear and Finding Criminals
← 上一题 下一题 →

A10403 | Bear and Finding Criminals

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

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 city $a$ . 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.

输入格式

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 $t_{1},t_{2},...,t_{n}$ ( $0<=t_{i}<=1$ ). There are $t_{i}$ criminals in the $i$ -th city.

输出格式

Print the number of criminals Limak will catch.

输入输出样例

输入 #1
6 3
1 1 1 0 1 0
输出 #1
3
输入 #2
5 2
0 0 0 1 0
输出 #2
1
C++ 编辑器
输入
输出