Submission
Status:
PPPPPP--P-
Score: 70
User: Nathlol2
Problemset: Fool's Compensation
Language: cpp
Time: 0.009 second
Submitted On: 2025-03-16 20:45:56
#include <bits/stdc++.h>
using namespace std;
const int N = 1000005;
vector<int> dp(N, 1000), a(N);
int32_t main(){
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
for(int i = 1;i<=n;i++){
cin >> a[i];
}
for(int i = 2;i<=n;i++){
if(a[i] > a[i - 1]){
dp[i] = dp[i - 1] + 1000;
}else if(a[i] == a[i - 1]){
dp[i] = dp[i - 1];
}
}
for(int i = n - 1;i>=1;i--){
if(a[i] > a[i + 1]){
dp[i] = max(dp[i], dp[i + 1] + 1000);
}else if(a[i] == a[i + 1]){
dp[i] = max(dp[i], dp[i + 1]);
}
}
int s = 0;
for(int i = 1;i<=n;i++){
s += dp[i];
//cout << dp[i] << " ";
}
cout << s << '\n';
}