hdu find the max(1594)
来源:互联网 发布:nba95年总决赛数据 编辑:程序博客网 时间:2024/06/05 14:06
find the max
Time Limit: 1000/1500 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 613 Accepted Submission(s): 286
Problem Description
有一个离散函数f(x),x = {1, 2, ,,,,N},f(x)<2^31。现在要找出2个点i,j, 使得函数在这2点之间的点都在这2点连线下方,且此连线的斜率的绝对值越大越好。
Input
输入包括多个测试实例。每个测试实例包括2行,第一行为一个整数N,2 <= N <= 100000, 然后是N个整数f(x),x=1,2...N,读到文件结束符为止.
Output
对于每个测试实例输出找到的i和j,如果有多个答案,输出字典序最小的一个。
Sample Input
31 2 332 6 4
Sample Output
1 21 2
相邻两个点之间的斜率的绝对值 最大即可。
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1594
小乐一下:
当我们分折不出问题时,至少可以猜一下也是好的。
代码:
#include<cstdio>#include<cstring>int s[100010];struct Node{ int num; int i,j;}node[100010];int abs(int a){return a<0?-a:a;}int main(){ int n; int cnt; int maxs,temp; int i; while(scanf("%d",&n)!=EOF){ for(i = 1;i<=n;i++){ scanf("%d",&s[i]); } cnt = 0; maxs = -1; for(i = 2;i<=n;i++){ node[cnt].num = abs(s[i]-s[i-1]); node[cnt].i = i-1; node[cnt].j = i; if(node[cnt].num > maxs) {temp = cnt;maxs = node[cnt].num;} cnt++; } printf("%d %d\n",node[temp].i,node[temp].j); } return 0;}
伟大的梦想成就伟大的人,从细节做好,从点点滴滴做好,从认真做好。
0 0
- HDU 1594 find the max
- hdu find the max(1594)
- 杭电ACM HDU 1594 find the max
- hdu 1594 (find the max) (绝对值最大值比较大小)
- WOJ1032-Find the Max NORM
- HDU 2803 The Max
- HDU 2803 The MAX
- hdu 2803 The MAX
- HDU To The Max
- hdu 2803 The MAX
- The MAX HDU
- CSU 1317 Find the max Link
- HDU 1081 To the Max
- HDU 1081 To The Max
- HDU 1081 To The Max
- HDOJ/HDU 2803 The MAX
- hdu 1081 To The Max
- hdu 1081 to the max
- 快速求幂(位运算)
- iOS开发之Auto Layout入门
- js动态表格
- 数据结构习题集答案0
- 我理解的大小端存储
- hdu find the max(1594)
- 【算法学习笔记】11.数据结构基础 二叉树初步练习4
- EasyUI datagrid默认选中第一行
- HDU 4891 The Great Pan 模拟
- python 循环遍历字典元素
- 在ISE下分析和约束时序
- 熵编码--mpeg12video huffman编码
- HDU 1114 Piggy-Bank 完全背包的变形
- MFC生成Win7或XP风格