zoj 3809 水 2014 ACM牡丹江区域赛网赛

http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5341

第一题水题,水下大笑

//#pragma comment(linker, "/STACK:102400000,102400000")
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <map>
#include <set>
#include <queue>
using namespace std;

#define ls(rt) rt*2
#define rs(rt) rt*2+1
#define ll long long
#define ull unsigned long long
#define rep(i,s,e) for(int i=s;i<e;i++)
#define repe(i,s,e) for(int i=s;i<=e;i++)
#define CL(a,b) memset(a,b,sizeof(a))
#define IN(s) freopen(s,"r",stdin)
#define OUT(s) freopen(s,"w",stdout)
const ll ll_INF = ((ull)(-1))>>1;
const double EPS = 1e-8;
const int INF = 100000000;
const int MAXN = 100;
int h[MAXN];

int main()
{
    int ncase,n,ans;
    scanf("%d",&ncase);
    while(ncase--)
    {
        scanf("%d",&n);
        for(int i=0;i<n;i++)
            scanf("%d",&h[i]);
        ans=0;
        for(int i=1;i<n-1;i++)
        {
            if(h[i]>h[i-1] && h[i]>h[i+1])
                ans++;
        }
        printf("%d\n",ans);
    }
    return 0;
}


你可能感兴趣的:(zoj 3809 水 2014 ACM牡丹江区域赛网赛)