You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.2 KiB
55 lines
1.2 KiB
#include <bits/stdc++.h>
|
|
|
|
using namespace std;
|
|
|
|
int main() {
|
|
//输入+输出重定向
|
|
freopen("../1350.in", "r", stdin);
|
|
freopen("../1350.out", "w", stdout);
|
|
|
|
int n;
|
|
cin >> n;
|
|
//声明一个动态大小的a数组
|
|
int a[1000] = {0};
|
|
for (int i = 0; i < n; ++i) {
|
|
cin >> a[i];
|
|
}
|
|
//最大值
|
|
int m = INT32_MIN;
|
|
//每个成员,左右看,到自己小的停止,查找个数
|
|
for (int i = 0; i < n; ++i) {
|
|
//得分
|
|
int score = 0;
|
|
int p = i;
|
|
//自己是多少
|
|
int now = a[i];
|
|
//左
|
|
while (p >= 0) {
|
|
//向左
|
|
if (a[p] >= now) {
|
|
score += now;
|
|
p--;
|
|
} else {
|
|
break;
|
|
}
|
|
}
|
|
//右
|
|
p = i + 1;
|
|
while (p < n) {
|
|
//向左
|
|
if (a[p] > now) {
|
|
score += now;
|
|
p++;
|
|
} else {
|
|
break;
|
|
}
|
|
}
|
|
if (score > m)m = score;
|
|
}
|
|
cout << m << endl;
|
|
//关闭文件
|
|
fclose(stdin);
|
|
fclose(stdout);
|
|
return 0;
|
|
}
|