303516: CF680B. Bear and Finding Criminals

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Bear and Finding Criminals

题意翻译

比尔兰有n个城市,编号为 $1$ 到 $n$ 。城市排成一排。城市 $i$ 和 $j$ 之间的距离等于 $|i - j |$ 。 利马克是一名警官。他住在a市,他的工作是抓罪犯。这很难,因为他不知道罪犯在哪个城市。不过,他知道每个城市最多只能有一个罪犯。 利马克将使用BCD。BCD会告诉利马克在距离a市每一段距离内有多少罪犯,然后,利马克可以在他确信一定有罪犯的每个城市抓到一个罪犯。 你知道罪犯在哪个城市。数一数利马克在使用BCD后将抓获的罪犯人数。

题目描述

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

说明

In the first sample, there are six cities and Limak lives in the third one (blue arrow below). Criminals are in cities marked red. ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF680B/53b34f04c80c68b5459bb6787b79d861ce7bb49e.png)Using the BCD gives Limak the following information: - There is one criminal at distance $ 0 $ from the third city — Limak is sure that this criminal is exactly in the third city. - There is one criminal at distance $ 1 $ from the third city — Limak doesn't know if a criminal is in the second or fourth city. - There are two criminals at distance $ 2 $ from the third city — Limak is sure that there is one criminal in the first city and one in the fifth city. - There are zero criminals for every greater distance. So, Limak will catch criminals in cities $ 1 $ , $ 3 $ and $ 5 $ , that is $ 3 $ criminals in total. In the second sample (drawing below), the BCD gives Limak the information that there is one criminal at distance $ 2 $ from Limak's city. There is only one city at distance $ 2 $ so Limak is sure where a criminal is. ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF680B/9b09abcaba16810167119bac2c883bc8bf99b11b.png)

Input

题意翻译

比尔兰有n个城市,编号为 $1$ 到 $n$ 。城市排成一排。城市 $i$ 和 $j$ 之间的距离等于 $|i - j |$ 。 利马克是一名警官。他住在a市,他的工作是抓罪犯。这很难,因为他不知道罪犯在哪个城市。不过,他知道每个城市最多只能有一个罪犯。 利马克将使用BCD。BCD会告诉利马克在距离a市每一段距离内有多少罪犯,然后,利马克可以在他确信一定有罪犯的每个城市抓到一个罪犯。 你知道罪犯在哪个城市。数一数利马克在使用BCD后将抓获的罪犯人数。

加入题单

上一题 下一题 算法标签: