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 ...
随机推荐
- CSS学习笔记----CSS3自定义字体图标
响应式网页字体图标 作者:大漠 日期:2014-01-28 点击:3220 @font-face Responsive 本文由大漠根据Jason的<Responsive Webfont Icon ...
- C# 根据ADO.NET数据库连接字符串构建EntityFrame数据库连接字符串
为了保持开发效率,以及保持代码优雅,项目中引用了EntityFrame.但是又因为某些报表功能需要大量计算,所以又要求直接使用ADO.NET,调用存储过程进行计算. 于是乎webconfig文件中就会 ...
- CSS3学习
1.CSS3边框 border-radius:创建圆角边框 border-radius:25px; -moz-border-radius:25px; /* 老的 Firefox */ box-shad ...
- SQL数据库约束
针对维护数据库的完整性,关系型数据库SQL提供了数据约束来管理数据,常用的约束有:外键.唯一.主键. 主键约束:标识数据的唯一,便于数据查询索引: 唯一约束:保证数据的唯一性:常用语法 alter t ...
- Java代码实现excel数据导入到Oracle
1.首先需要两个jar包jxl.jar,ojdbc.jar(注意版本,版本不合适会报版本错误)2.代码: Java代码 import java.io.File; import java.io.Fi ...
- float 的有效数字为七位是怎么得出来的
以下内容来自CSDN网友xian_wwq的回答(http://bbs.csdn.net/topics/390874239): float: 1bit(符号位) 8bits(指数位) 23bits( ...
- [Tools] 使用work2013发布博客
参考园子里推荐的方式,觉得使用word发布挺好的,尝试了一下,还不错,记录下来备用 参考连接: http://www.cnblogs.com/liuxianan/archive/2013/04/1 ...
- HDU 4251 The Famous ICPC Team Again 主席树
The Famous ICPC Team Again Problem Description When Mr. B, Mr. G and Mr. M were preparing for the ...
- 【vijos】P1514天才的记忆
描述 从前有个人名叫W and N and B,他有着天才般的记忆力,他珍藏了许多许多的宝藏.在他离世之后留给后人一个难题(专门考验记忆力的啊!),如果谁能轻松回答出这个问题,便可以继承他的宝藏.题目 ...
- wpf window set window的owner
[DllImport("user32.dll")] public static extern IntPtr GetAncestor(IntPtr hWnd, int f ...