Submission
Status:
PPPPP-----
Subtask/Task Score:
50/100
Score: 50
User: Mano
Problemset: Fool's Compensation
Language: cpp
Time: 0.002 second
Submitted On: 2026-03-12 13:10:19
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int x, ans = 0;
cin >> x;
vector<int> arr(x);
vector<int> loan(x, 1000);
for (int i = 0; i < x; i++) {
cin >> arr[i];
}
for (int i = 1; i < x; i++) {
if (arr[i] > arr[i - 1]) {
loan[i] = loan[i - 1] + 1000;
}
}
for (int i = x - 2; i >= 0; i--) {
if (arr[i] > arr[i + 1]) {
loan[i] = max(loan[i], loan[i + 1] + 1000);
}else if(arr[i]==arr[i+1]){
loan[i]=loan[i+1];
}
}
for (int i = 0; i < x; i++) {
ans += loan[i];
//cout<<loan[i]<<" ";
}
cout << ans << endl;
}