hdu6570Wave (暴力求解)
1) It contains at least two
elements;
2) All elements at odd positions are the same;
3) All elements
at even positions are the same;
4) Elements at odd positions are NOT the same
as the elements at even positions.
You are given a series with length n. Avin
asks you to find the longest "wave" subseries. A subseries is a subsequence of a
series.
000, 1 ≤ c ≤ 100). The second line contains n integers whose range is [1, c],
which represents the series. It is guaranteed that there is always a "wave"
subseries.
1 2 1 3 2
#include<iostream>
#include<cstdio>
using namespace std;
int num[100005];
struct node{
int number,quanlity;//第一个存储表示的是哪一个数,第二个表示这个数的个数
}d[105];
int cmp(struct node x,struct node y){
return x.quanlity>y.quanlity;
}
int main(){
int n,c;
scanf("%d%d",&n,&c);
for(int i=0;i<=100;i++)
d[i].quanlity=0,d[i].number=i;
for(int i=0;i<n;i++)
scanf("%d",&num[i]),d[num[i]].quanlity++;
/* for(int i=0;i<c;i++)
printf("%d %d\n",d[i].number,d[i].quanlity);*/
int maxn=0;
for(int i=0;i<c-1;i++){
for(int ii = i+1;ii<c;ii++){
int s = 1 , x = d[i].number , y = d[ii].number , mm , j;
for(j=0;j<n;j++){if(num[j]==x||num[j]==y) {mm=num[j];break;}}
for(;j<n;j++){
if(num[j]==x||num[j]==y){
if(num[j]!=mm) s++,mm=num[j];
}
}
if(s>maxn) maxn=s;
}
}
printf("%d\n",maxn);
return 0;
}
//10 4
//1 4 3 1 3 1 2 2 1 2
hdu6570Wave (暴力求解)的更多相关文章
- POJ 1562(L - 暴力求解、DFS)
油田问题(L - 暴力求解.DFS) Description The GeoSurvComp geologic survey company is responsible for detecting ...
- 逆向暴力求解 538.D Weird Chess
11.12.2018 逆向暴力求解 538.D Weird Chess New Point: 没有读好题 越界的情况无法判断,所以输出任何一种就可以 所以他给你的样例输出完全是误导 输出还搞错了~ 输 ...
- 隐型马尔科夫模型(HMM)向前算法实例讲解(暴力求解+代码实现)---盒子模型
先来解释一下HMM的向前算法: 前向后向算法是前向算法和后向算法的统称,这两个算法都可以用来求HMM观测序列的概率.我们先来看看前向算法是如何求解这个问题的. 前向算法本质上属于动态规划的算法,也就是 ...
- BestCoder Round #79 (div.2)-jrMz and angles,,暴力求解~
jrMz and angle Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Other ...
- <字符串匹配>KMP算法为何比暴力求解的时间复杂度更低?
str表示文本串,m表示模式串; str[i+j] 和 m[j] 是正在进行匹配的字符; KMP的时间复杂度是O(m+n) , 暴力求解的时间复杂度是O(m*n) KMP利用了B[0:j]和A[i ...
- HDU 4462 Scaring the Birds (暴力求解,二进制法)
题意:给定一个 n*n的矩阵,在一些位置放上稻草人,每个稻草人的范围是一定,问你最少几个能覆盖整个矩阵. 析:稻草人最多才10个,所以考虑暴力,然后利用二进制法,很容易求解,并且时间很少0ms,注意有 ...
- ZOJ 2856 Happy Life 暴力求解
因为是Special Judge 的题目,只要输出正确答案即可,不唯一 暴力力求解, 只要每次改变 happiness 值为负的人的符号即可. 如果计算出当前人的 happiness 值为负,那么将其 ...
- (暴力求解)Encoding HDU1020
Encoding 链接:http://acm.hdu.edu.cn/showproblem.php?pid=1020 Time Limit: 2000/1000 MS (Java/Others) ...
- HDU 2601An easy problem-素数的运用,暴力求解
id=17433" target="_blank" style="color:blue; text-decoration:none">An ea ...
随机推荐
- 关于html5 video
获取视频长度 <video id="video" width="200px" height="auto" src="vide ...
- Spring事务嵌套引发的问题--Transaction rolled back because it has been marked as rollback-only
转载https://blog.csdn.net/f641385712/article/details/80445912 读了两边才找到问题
- Elasticsearch7.X 入门学习第九课笔记-----聚合分析Aggregation
原文:Elasticsearch7.X 入门学习第九课笔记-----聚合分析Aggregation 版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明. ...
- Linux安装软件-CentOS和Ubuntu介绍
开发十年,就只剩下这套架构体系了! >>> 不同Linux发行版的软件安装会有不同的方式,其中CentOS安装软件的主要方式是rpm和yum,Ubuntu可以使用apt-get, ...
- java 进销存管理 商户管理 库存管理 springmvc SSM 项目源码
统介绍: 1.系统采用主流的 SSM 框架 jsp JSTL bootstrap html5 (PC浏览器使用) 2.springmvc +spring4.3.7+ mybaits3.3 SSM 普 ...
- Mybatis之:SqlSessionFactory、SqlSession
public class CountryMapperTest { private static SqlSessionFactory sqlSessionFactory; @BeforeClass pu ...
- Cobaltstrike系列教程(三)-beacon详解
0x000--前文 Cobaltstrike系列教程(一)-简介与安装 Cobaltstrike系列教程(二)-Listner与Payload生成 heatlevel 0x001-Beacon详解 1 ...
- sonar-runner命令模式运行sonar
适用环境:该种配置的模式适用于本地调试模式 前提条件:在工程路径下创建sonar-project.properties文件 该客户端的路径在系统配置文件中进行了定义 alias sonar-runne ...
- 循环神经网络(LSTM和GRU)(1)
循环神经网络的简单实现: import tensorflow as tf x=[1,2] state=[0.0,0.0] w_cell_state=np.array([[0.1,0.2],[0.3,0 ...
- 吸$DN
旧博客:https://blog.csdn.net/gmh77 从几年前开始用CSDN,见证了CSDN是如何一步步走向辣鸡的 广告?ABP 登录看文章?雨我无瓜账号常年不退 分类要慢慢点也可以接受 前 ...