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