zoj 3809 枚举水题 (2014牡丹江网赛 A题)

题目大意:给出一列取样的几个山的高度点,求山峰有几个?

Sample Input

2
9
1 3 2 4 6 3 2 3 1
5
1 2 3 4 5
Sample Output

3
0

 1 # include <iostream>
 2 # include <cstdio>
 3 # include <cstring>
 4 # include <algorithm>
 5 # include <cmath>
 6 # define LL long long
 7 using namespace std ;
 8
 9 int a[88] ;
10
11 int main ()
12 {
13     //freopen("in.txt","r",stdin) ;
14     int T ;
15     cin>>T ;
16     while(T--)
17     {
18         int n ;
19         int i ;
20         cin>>n ;
21         for (i = 1 ; i <= n ; i++)
22             cin>>a[i] ;
23         int sum = 0 ;
24         for (i = 2 ; i <= n-1 ; i++)
25         {
26             if (a[i] > a[i-1] && a[i] > a[i+1])
27                 sum++ ;
28         }
29         cout<<sum<<endl ;
30     }
31
32
33     return 0 ;
34 }

时间: 2024-12-05 20:01:30

zoj 3809 枚举水题 (2014牡丹江网赛 A题)的相关文章

ACM学习历程——ZOJ 3829 Known Notation (2014牡丹江区域赛K题)(策略,栈)

Description Do you know reverse Polish notation (RPN)? It is a known notation in the area of mathematics and computer science. It is also known as postfix notation since every operator in an expression follows all of its operands. Bob is a student in

zoj 3827 Information Entropy(2014牡丹江区域赛I题)

Information Entropy Time Limit: 2 Seconds      Memory Limit: 65536 KB      Special Judge Information Theory is one of the most popular courses in Marjar University. In this course, there is an important chapter about information entropy. Entropy is t

zoj 3818 2014牡丹江网赛

http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5350 昨天写死都是WA,今天按枚举a,b,c的长度以及调用string类的函数substr,1A..... 还是调用系统函数代码能短很多而且代码短意味着出错机会少&思考的逻辑更容易...... 写贴个昨天的WA代码  还是不明白为啥WA..... //#pragma comment(linker, "/STACK:102400000,102400000")

ACM学习历程——ZOJ 3822 Domination (2014牡丹江区域赛 D题)(概率,数学递推)

Description Edward is the headmaster of Marjar University. He is enthusiastic about chess and often plays chess with his friends. What's more, he bought a large decorative chessboard with N rows and M columns. Every day after work, Edward will place

zoj 3817 2014牡丹江网赛 字符串哈希

http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5349 比赛的时候没看这道题,遗憾,不过想到算法不难,但是写代码比较考代码能力,我自己写了两次都不行,还是看了别人代码,写下了这个 学到: 1.hash字符串第一个下表为0的空起来,写起来方便 2.hash匹配的全部情况就是以text串的所有位置为起点做匹配,当text比patern小而且text可以循环时,这么确定 3.dfs的时候,为了加快,可以预估计至少需要匹配多长 in

hdu 5003 模拟水题 (2014鞍山网赛G题)

你的一系列得分 先降序排列 再按0.95^(i-1)*ai 这个公式计算你的每一个得分 最后求和 Sample Input12530 478Sample Output984.1000000000 1 # include <iostream> 2 # include <cstdio> 3 # include <algorithm> 4 # include <map> 5 # include <cmath> 6 # define LL long lo

zoj 3822 Domination(2014牡丹江区域赛D题)

Domination Time Limit: 8 Seconds      Memory Limit: 131072 KB      Special Judge Edward is the headmaster of Marjar University. He is enthusiastic about chess and often plays chess with his friends. What's more, he bought a large decorative chessboar

zoj 3819(2014牡丹江区域赛 A题 )

题意:给出A班和B班的学生成绩,如果bob(A班的)在B班的话,两个班级的平均分都会涨.求bob成绩可能的最大,最小值. A班成绩平均值(不含BOB)>A班成绩平均值(含BOB) && B班成绩平均值(不含BOB)< B班成绩平均值(含BOB) 化简后得 B班成绩平均值(不含BOB) < X < A班成绩平均值(不含BOB) Sample Input 24 35 5 54 4 36 55 5 4 5 31 3 2 2 1Sample Output 4 42 4 1

ZOJ 3827 Information Entropy (2014牡丹江区域赛)

题目链接:ZOJ 3827 Information Entropy 根据题目的公式算吧,那个极限是0 AC代码: #include <stdio.h> #include <string.h> #include <math.h> const double e=exp(1.0); double find(char op[]) { if(op[0]=='b') return 2.0; else if(op[0]=='n') return e; else if(op[0]=='