Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: Apimuk
Problemset: Fool's Compensation
Language: cpp
Time: 0.002 second
Submitted On: 2026-02-23 21:38:35
#include<bits/stdc++.h>
using namespace std;
int main(){
cin.tie(nullptr)->sync_with_stdio(false);
int n;
cin >> n;
vector<long long> a(n), give(n, 1000);
for(int i = 0; i < n; i++){
cin >> a[i];
}
for(int i = 1; i < n; i++){
if(a[i] > a[i-1]){
give[i] = give[i-1] + 1000;
}
else if(a[i] == a[i-1]){
give[i] = give[i-1];
}
}
for(int i = n-2; i >= 0; i--){
if(a[i] > a[i+1]){
give[i] = max(give[i], give[i+1] + 1000);
}
else if(a[i] == a[i+1]){
give[i] = give[i+1];
}
}
long long sum = 0;
for(long long x : give) sum += x;
cout << sum << "\n";
}