Submission

Status:
PPPPPPPPPP

Score: 100

User: Angonnyyy

Problemset: Fool's Compensation

Language: cpp

Time: 0.002 second

Submitted On: 2025-03-17 22:31:55

#include<bits/stdc++.h>
using namespace std;

int main(){
    ios::sync_with_stdio(0);cin.tie(0);
    int n;
    long long int total=0;
    cin>>n;
    vector<int>salary(n,1),score(n);
    for(int i = 0;i<n;i++){
        cin >> score[i];
    }
    for(int i = 0;i<n-1;i++){
        if(score[i]<score[i+1]){
            salary[i+1]=salary[i]+1;
        }
        else if(score[i]==score[i+1]){
            salary[i+1]=salary[i];
        }
    }
    for(int i = n-1;i>0;i--){
        if(score[i]<score[i-1] && salary[i]>=salary[i-1]){//i-1 have more
            salary[i-1]=salary[i]+1;
        }
        else if(score[i]==score[i-1]){//compare pick most
            salary[i-1]=max(salary[i-1],salary[i]);
            salary[i]=salary[i-1];
            
        }
        total+=salary[i];
    }
    total+=salary[0];
    total*=1000;
    cout<<total;
}