// ConsoleApplication5.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include<vector>
#include<iostream>
using namespace std;
class MaxInnerRec {
public:
int countArea(vector<int> A, int n) {
vector<int> areas;
for (int i = 0; i < A.size(); i++)
{
int sum = A[i];
for (int before = i-1; before >= 0; before--)
{
if (A[before] < A[i]) {
break;
}
else {
sum = sum + A[i];
}
}
for (int afer = i + 1; afer < A.size(); afer++)
{
if (A[afer] < A[i]) {
break;
}
else {
sum = sum + A[i];
}
}
areas.push_back(sum);
}
int maxArea= areas[0];
for (int i = 1; i < areas.size(); i++)
{
if (maxArea < areas[i])
{
maxArea = areas[i];
}
}
return maxArea;
}
};
int main()
{
vector<int> A = { 2,7,9,4,1 };
MaxInnerRec maxInnerRec;
cout << maxInnerRec.countArea(A,5)<<endl;
return 0;
}