Submission
Status:
--PP------
Subtask/Task Score:
20/100
Score: 20
User: theem1502
Problemset: Fool's Compensation
Language: cpp
Time: 0.007 second
Submitted On: 2026-02-27 22:02:19
#include <bits/stdc++.h>
using namespace std;
int main() {
int num;
cin >> num;
vector<int> thearray(num);
priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> theq;
for (int i = 0; i < num; i++) {
cin >> thearray[i];
theq.push({thearray[i], i});
}
vector<int> visited(num, -1);
while(!theq.empty()) {
int thenum = 2;
int first = theq.top().first, second = theq.top().second;
// cout << "first = " << first << "\n";
theq.pop();
if (visited[second] != -1) {
continue;
}
visited[second] = 1;
int counter = 1;
while(second + counter < num && thearray[second + counter] > thearray[second + counter - 1])
{
if (visited[second + counter] != -1) {
goto here;
}
visited[second+ counter] = thenum;
// cout << second + counter << "\n";
here:
counter++;
thenum++;
}
counter = -1;
thenum = 2;
while(second + counter >= 0 && thearray[second + counter] > thearray[second + counter + 1])
{
if (visited[second + counter] != -1) {
goto there;
}
visited[second+ counter] = thenum;
// cout << "debug " << second + counter << "\n";
there:
counter--;
thenum++;
}
}
int sum = 0;
for (int i = 0; i < num; i++) {
sum += visited[i];
}
cout << 1000 * sum;
}