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