码迷,mamicode.com
首页 > 其他好文 > 详细

HDU 1594 find the max

时间:2019-06-01 19:02:43      阅读:82      评论:0      收藏:0      [点我收藏+]

标签:inf   name   ase   namespace   find   href   temp   cstring   post   

数序问题。


题意是说 一个数列 a1,a2,……ai,……an;? x=i , y = ai;找两个点斜率绝对值。!最大。

第一次没找绝对值,……认真读题。

。。

x 每次加1 。

仅仅须要找 相邻的 ai 是否是最大就好了。


#include<cstdio>
#include<cstring>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<stack>
#include<iostream>
#include<list>
#include<set>
#include<cmath>
#define INF 0x7fffffff
#define eps 1e-6
#define LL long long
using namespace std;
int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        int a,b,m=0,tmp;
        scanf("%d",&a);
        for(int i=1;i<n;i++)
        {
            scanf("%d",&b);
            if(m<abs(a-b))
                m=abs(a-b),tmp=i;
            a=b;
        }
        printf("%d %d\n",tmp,tmp+1);
    }
}


HDU 1594 find the max

标签:inf   name   ase   namespace   find   href   temp   cstring   post   

原文地址:https://www.cnblogs.com/ldxsuanfa/p/10960605.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
分享档案
周排行
mamicode.com排行更多图片
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!