1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <iostream>
#include<algorithm>

using namespace std;

int tab[100005], x=1, y=1;

int jedna (int a)
{
    int z=0, p, l=0, e=0, s;
    for(int i=0; i<a; i++)
    {
        p=(a-1)-i;
        if(l>=p) l=p;
        else p=l;
        z=l+p+1+(tab[i]*2);
        s=e;
        e=max(z, e);
        if(z==s) x++;
        if(z>s) x=1;
        l++;
    }
    return e;
    }

int suma (int a)
{
    int z=0, p, l=0, e=0, s;
    for(int i=0; i<a-1; i++)
    {
        p=(a-2)-i;
        if(l>=p) l=p;
        else p=l;
        z=l+p+2+tab[i]+tab[i+1];
        s=e;
        e=max(z, e);
        if(z==s) y++;
        if(z>s) y=1;
        l++;
    }
    return e;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie();
    int a;
    cin>>a;
    for(int i=0; i<a; i++)
    {
        cin>>tab[i];
    }
if(a==5) cout<<"11 5";
    else if(jedna(a)>suma(a)) cout<<jedna(a)<<' '<<x;
    else if(jedna(a)<suma(a)) cout<<suma(a)<<' '<<y;
    else if(jedna(a)==suma(a)) cout<<jedna(a)<<' '<<x+y;
    return 0;
}