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
#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
    int n, duzo = 0,ile=0;
    cin >> n;
    vector<int>a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++)
    {
        for (int q = i; q < n; q++)
        {
            vector<int>b;
            int sum=0;
            for (int w = i; w < q+1; w++)
            {
                b.push_back(a[w]);
                sum += a[w];
            }
            sort(b.begin(), b.end());
            int liczba;
            if (b.size() % 2 == 0)
            {
                liczba = b[b.size() / 2] + b[b.size() / 2 - 1] + b.size();
            }
            else
            {
                liczba = b[b.size() / 2]*2+b.size();
            }
            if (duzo == liczba)
            {
                ile++;
            }
            if (duzo < liczba)
            {
                ile = 1;
                duzo = liczba;
            }
        }
    }
    cout << duzo << " " << ile << endl;
}