hdu1003

来源:互联网 发布:java适配器是什么 编辑:程序博客网 时间:2024/06/05 19:24
#include <iostream>#include <algorithm>#include <cmath>#include <cstdio>using namespace std;#define oo (~0U >> 1)#define MAXN 100000 + 10int temp[MAXN];void input(){    int t, x, n, k = 0;    cin >> t;    while (t--)    {        char ch;        long long ans = -(long long)oo, a = 0;        int p1 = 0, p2 = 0, p = 0;        cin >> n;        cin >> x;        ans = a = x;        for (int i = 1; i < n; i++)        {            cin >> x;            if (a < 0)            {                a = x;                p = i;            }            else            {                a += x;            }            if (a > ans)            {                ans = a;                p1 = p;                p2 = i;            }        }        cout << "Case " << ++k << ":" << endl;        cout << ans << ' ' << p1 + 1 << ' ' << p2 + 1 << endl;        if (t)        {            cout << endl;        }    }}int main(){    input();    return 0;}

原创粉丝点击