Codeforces Round #245 (Div. 2) B - Balls Game
暴利搜索即可
#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的更多相关文章
- 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 ...
- 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 ...
- Codeforces Round #245 (Div. 1) 429D - Tricky Function 最近点对
D. Tricky Function Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 codeforces.com/problemset/problem/42 ...
- Codeforces Round #245 (Div. 1) B. Working out (简单DP)
题目链接:http://codeforces.com/problemset/problem/429/B 给你一个矩阵,一个人从(1, 1) ->(n, m),只能向下或者向右: 一个人从(n, ...
- Codeforces Round #245 (Div. 1) B. Working out (dp)
题目:http://codeforces.com/problemset/problem/429/B 第一个人初始位置在(1,1),他必须走到(n,m)只能往下或者往右 第二个人初始位置在(n,1),他 ...
- Codeforces Round #245 (Div. 2)
版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/yew1eb/article/details/25609981 A Points and Segmen ...
- Codeforces Round #245 (Div. 1) B. Working out dp
题目链接: http://codeforces.com/contest/429/problem/B B. Working out time limit per test2 secondsmemory ...
- 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 ...
- 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 ...
随机推荐
- Oracle Redo Log
http://blog.itpub.net/27039319/viewspace-2120623/ 11.2和11.2以下的区别:http://blog.itpub.net/27039319/view ...
- Hibernate的ORM原理和实现
>>Hibernate和ORM ORM的全称是Object Relational Mapping,即对象关系映射.它的实现思想就是将关系数据库中表的数据映射成为对象,以对象的形式展现,这样 ...
- 自制工具:迅速打开一个Node 环境的Playground
需求 经常有这种情况,写代码的时候需要实验种想法,亟需一种playground 环境来玩耍.如果是前端的话可以打开chrome 的控制台,但是如果是Node 的话就比较麻烦了.我要打开我的存放试验代码 ...
- js setTimeout运用
js setTimeout运用 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "ht ...
- 1-03 Sql Sever 的身份验证模式
身份验证分为: 1:Windows身份验证. 1:Sql Sever身分验证. 每种验证的具体方式: 1Windows的验证方式 点击下拉框,有这两种验证方式,Windows验证只需要启动服务即可. ...
- cocos2d-x CCScrollView和CCTableView的使用(转载)
转载请注明来自:Alex Zhou的程序世界,本文链接:http://codingnow.cn/cocos2d-x/1024.html //============================== ...
- 基于能量收集的智能家居-2013国家级大学生创业实践项目申报_商业计划书_V0.2
SmartHome项目商业计划 基于能量收集的 免电池无线智能家居系统 IA-SmartHome团队 2012.12 l 基于无线的智能家居解决方案,节省施工成本: l 基于能 ...
- JS 正则表达式详解
在此提供相关的链接,请访问: http://www.cnblogs.com/dolphinX/p/3486214.html http://www.cnblogs.com/dolphinX/p/3486 ...
- Codeforces Round #227 (Div. 2) E. George and Cards set内二分+树状数组
E. George and Cards George is a cat, so he loves playing very much. Vitaly put n cards in a row in ...
- slide.js使用文档
<!doctype html> <head> <script src="js/jquery-latest.min.js"></script ...