Submission

Status:

PPPPPP--P-

Subtask/Task Score:

70/100

Score: 70

User: tHeNyXs

Problemset: Fool's Compensation

Language: cpp

Time: 0.303 second

Submitted On: 2026-03-06 10:39:54

#include <bits/stdc++.h>
using namespace std;
int main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    int n; cin >> n;
    vector<int> a(n+2, 0);
    for (int i = 1; i <= n; ++i) cin >> a[i];
    vector<int> ic(n+2, 0);
    for (int i = 1; i <= n; ++i) ic[i] = 1000;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            if (a[j] > a[j-1] && ic[j] <= ic[j-1]) {
                ic[j] = ic[j-1] + 1000;
            }
            if (a[j] > a[j+1] && ic[j] <= ic[j+1]) {
                ic[j] = ic[j+1] + 1000;
            }
            if (a[j] == a[j+1] && ic[j] != ic[j+1]) {
                ic[j] = max(ic[j], ic[j+1]);
                ic[j+1] = ic[j];
            }
            if (a[j] == a[j-1] && ic[j] != ic[j-1]) {
                ic[j] = max(ic[j], ic[j-1]);
                ic[j-1] = ic[j];
            } 
        }
        // for (int j = 1; j <= n; ++j) {
        //     cout << "I : " << j << " | Income : " << ic[j] << '\n' ;
        // }
        // cout << '\n';
    }

    int sum = 0;
    for (int i = 1; i <= n; ++i) sum += ic[i];
    cout << sum;

    return 0;
}