codeforces 680B B. Bear and Finding Criminals(水题)

Posted LittlePointer

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了codeforces 680B B. Bear and Finding Criminals(水题)相关的知识,希望对你有一定的参考价值。

题目链接:

B. Bear and Finding Criminals

//#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <queue>
#include <cmath>
#include <map>
#include <cstring>
#include <algorithm>
#include <cstdio>

using namespace std;
#define Riep(n) for(int i=1;i<=n;i++)
#define Riop(n) for(int i=0;i<n;i++)
#define Rjep(n) for(int j=1;j<=n;j++)
#define Rjop(n) for(int j=0;j<n;j++)
#define mst(ss,b) memset(ss,b,sizeof(ss));
typedef long long LL;
template<class T> void read(T&num) {
    char CH; bool F=false;
    for(CH=getchar();CH<0||CH>9;F= CH==-,CH=getchar());
    for(num=0;CH>=0&&CH<=9;num=num*10+CH-0,CH=getchar());
    F && (num=-num);
}
int stk[70], tp;
template<class T> inline void print(T p) {
    if(!p) { puts("0"); return; }
    while(p) stk[++ tp] = p%10, p/=10;
    while(tp) putchar(stk[tp--] + 0);
    putchar(\n);
}

const LL mod=1e9+7;
const double PI=acos(-1.0);
const LL inf=1e14;
const int N=1e5+15;

int n,a,t[200];
int main()
{
   read(n);read(a);
   Riep(n)read(t[i]);
   int ans=0;
   for(int i=0;i<=n;i++)
   {
       if(a-i>0&&a+i<=n)
       {
           if(i==0)ans+=t[a];
          else if(t[a-i]&&t[a+i])ans+=2;
       }
       else if(a-i<1&&a+i<=n)
       {
           ans+=t[a+i];
       }
       else if(a-i>=1&&a+i>n)ans+=t[a-i];
   }
   cout<<ans<<"\n";


        return 0;
}

 

以上是关于codeforces 680B B. Bear and Finding Criminals(水题)的主要内容,如果未能解决你的问题,请参考以下文章

Codeforces653 B. Bear and Compressing(dp)

B. Bear and Finding Criminals1000 / 双指针

cf B. Bear and Compressing

codeforces 653A A. Bear and Three Balls(水题)

Codeforce 573A. Bear and Poker

[2016-04-04][codeforces][639][A][Bear and Displayed Friends]