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 ...
随机推荐
- mysql可以用这种方式<<! 输入内容 ! 做成脚本
以这种文件式做交接NB!!!!! [root@NB test]# mysql -uroot -p$passwd <<! > use mysql > select user,ho ...
- android 屏幕旋转
转自:http://blog.csdn.net/oyzhizhong/article/details/8131799 屏是LANDSCAPE的,要让它默认显示为PORTRAIT. 1.kernel里要 ...
- sdut 2610:Boring Counting(第四届山东省省赛原题,划分树 + 二分)
Boring Counting Time Limit: 3000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 In this problem you a ...
- FTP的20、21端口,工作模式
什么是FTP? FTP就是文件传输协议 File Transfer Protocol 的缩写. FTP端口号是多少? 21 FTP的端口号能改吗? 能 ftp的端口号20.21有何区别? 一个是数据端 ...
- Android学习二_八:Animation的使用(一) (转)
一.Animations介绍 Animations是一个实现android UI界面动画效果的API,Animations提供了一系列的动画效果,可以进行旋转.缩放.淡入淡出等,这些效果可以应用在绝大 ...
- Android之Adapter用法总结-(转)
Android之Adapter用法总结 1.概念 Adapter是连接后端数据和前端显示的适配器接口,是数据和UI(View)之间一个重要的纽带.在常见的View(List View,Grid Vie ...
- codeforces 45C C. Dancing Lessons STL
C. Dancing Lessons There are n people taking dancing lessons. Every person is characterized by his ...
- Codeforces Round #174 (Div. 1) B. Cow Program(dp + 记忆化)
题目链接:http://codeforces.com/contest/283/problem/B 思路: dp[now][flag]表示现在在位置now,flag表示是接下来要做的步骤,然后根据题意记 ...
- 编译原理实习(应用预测分析法LL(1)实现语法分析)
#include<iostream> #include<fstream> #include<iomanip> #include<cstdio> #inc ...
- javase基础笔记4——异常/单例和类集框架
继承 extends final关键 多态 是在继承的基础上 接口 interface 异常 exception 包的访问可控制权限 private default protect public 异常 ...