poj2128

简单题

#include <cstdio>
#include <algorithm>
using namespace std;

#define maxn 50005

int n;
int f[maxn], g[maxn];

int main()
{
    scanf("%d", &n);
    if (n < 4)
    {
        puts("0");
        return 0;
    }
    f[0] = 0;
    for (int i = 1; i < n; i++)
        scanf("%d", &f[i]);
    for (int i = 1; i < n; i++)
        g[i] = f[i] - f[i - 1];
    int pos = min_element(g + 2, g + n - 1) - g;
    printf("%d\n", f[n - 1] + g[pos]);
    printf("%d %d %d 1\n", n, pos, pos + 1);
    return 0;
}
View Code

 

posted @ 2013-06-13 20:50  金海峰  阅读(220)  评论(1编辑  收藏  举报