暴利搜索即可

#include <iostream>
#include <vector>
#include <iostream> using namespace std; int main(){
int n,k,x;
cin >> n >> k >> x;
vector<int> c(n);
for(int i = ; i < n; ++ i) cin >> c[i];
int ans = ;
for(int i = ; i < n ; ++ i){
if(c[i] == x && c[i] == c[i-]){
int left = i-, right = i,s=,flag = ;
while(true){
int left_cnt = , right_cnt = ,j,k;
for(j = left; j >= && c[j] == c[left]; -- j) left_cnt++;
for(k = right; k < n && c[k] == c[right]; ++ k) right_cnt++;
if(left_cnt+right_cnt + flag >= && c[left] == c[right]){
left = j;right =k;
s+=left_cnt+right_cnt;
flag = ;
}else{
ans = max(ans,s);break;
}
}
} }
cout<<ans<<endl;
}

Codeforces Round #245 (Div. 2) B - Balls Game的更多相关文章

  1. Codeforces Round #245 (Div. 2) B. Balls Game 并查集

    B. Balls Game Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/430/problem ...

  2. Codeforces Round #158 (Div. 2) C. Balls and Boxes 模拟

    C. Balls and Boxes time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  3. Codeforces Round #245 (Div. 1) 429D - Tricky Function 最近点对

    D. Tricky Function Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 codeforces.com/problemset/problem/42 ...

  4. Codeforces Round #245 (Div. 1) B. Working out (简单DP)

    题目链接:http://codeforces.com/problemset/problem/429/B 给你一个矩阵,一个人从(1, 1) ->(n, m),只能向下或者向右: 一个人从(n, ...

  5. Codeforces Round #245 (Div. 1) B. Working out (dp)

    题目:http://codeforces.com/problemset/problem/429/B 第一个人初始位置在(1,1),他必须走到(n,m)只能往下或者往右 第二个人初始位置在(n,1),他 ...

  6. Codeforces Round #245 (Div. 2)

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/yew1eb/article/details/25609981 A Points and Segmen ...

  7. Codeforces Round #245 (Div. 1) B. Working out dp

    题目链接: http://codeforces.com/contest/429/problem/B B. Working out time limit per test2 secondsmemory ...

  8. Codeforces Round #245 (Div. 2) C. Xor-tree DFS

    C. Xor-tree Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/430/problem/C ...

  9. Codeforces Round #245 (Div. 2) A. Points and Segments (easy) 贪心

    A. Points and Segments (easy) Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/con ...

随机推荐

  1. 与你相遇好幸运,Sail.js定义其他主键

    uuid : { type: 'string', unique: true, required: true, primaryKey: true },

  2. 深入理解SELinux SEAndroid

    参考文章: 一. http://blog.csdn.net/innost/article/details/19299937 二. http://blog.csdn.net/innost/article ...

  3. hihoCoder 1391 Countries【预处理+排序+优先队列】2016北京网络赛

    题目:http://hihocoder.com/problemset/problem/1391 题目大意: A和B两个国家互射导弹,每个国家都有一个防御系统,在防御系统开启的时间内可以将到达本国的导弹 ...

  4. C++模板【转】

    1. 模板的概念. 我们已经学过重载(Overloading),对重载函数而言,C++的检查机制能通过函数参数的不同及所属类的不同.正确的调用重载函数.例如,为求两个数的最大值,我们定义MAX()函数 ...

  5. 传引用 C(转)

    转自:http://myturn.blog.hexun.com/15584978_d.html #include <iostream> using namespace std ; void ...

  6. JS对Array进行自定制排序

    JS对Array进行自定制排序,简单的做一个记录,代码如下所示: //Test function function myFunction(){ var myArr = new Array(); var ...

  7. DrawerLayout

        一.概述       DrawerLayout是官方提供的侧滑菜单,相比SliddingMenu,它更加轻量级.默认情况下,DrawerLayout可以设置左侧或者右侧滑出菜单.如下,   x ...

  8. (转载)一个用于Gnome桌面的下拉式终端: Guake 0.7.0 发布

    转自:https://linux.cn/article-5507-1.html Linux的命令行是最好.最强大的东西,它使新手着迷,并为老手和极客的提供极其强大的功能.那些在服务器和生产环境下工作的 ...

  9. Android 自定义实现switch开关按钮

    前几天在看蘑菇街上有个开关按钮: 就在想是怎样实现的,于是反编译了它的源码,但是这时得到了下面的几张图片: 图片对应的名称: 无色长条:switch_frame; 白色圆点:switch_btn_pr ...

  10. 2016.5.27 php测试中敏感度高,怎么调整

    在测试PHP代码的过程中,会遇到这样的问题:PHP提示Notice: Undefined variable,遇到这样的问题很纠结,但是很容易解决. 今天晚上,我就遇到了这样的问题,到网上搜索了很多解决 ...