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
#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n; cin>>n;
    vector<int>tab(n);vector<int>ar;
    for(int i = 0;i<n;++i){
        cin>>tab[i];
    }
    int best=-1; int ile=0;
    for(int i = 0;i<n;++i){
        for(int j = i;j<n;++j){
            ar.clear();
            for(int k = i;k<=j;++k){
                ar.push_back(tab[k]);
            }
            sort(ar.begin(),ar.end());
            int temp = ar[ar.size()/2]+ar[(ar.size()-1)/2]+ar.size();
            //cout<<ar.size()<<endl;
            if(temp>best){best=temp;ile=1;}
            else if(temp==best)++ile;
        }
    }
    cout<<best<<" "<<ile;
}