🔥 Burn Fat Fast. Discover How! 💪

import java.io.*; import java.util.*; import java.text.*; i | OFF CAMPUS UPDATES

import java.io.*;

import java.util.*;

import java.text.*;

import java.math.*;

import java.util.regex.*;



public class Solution {



public static void main(String[] args) {

/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */

Scanner scan = new Scanner(System.in);

int n = scan.nextInt();

int[] rating = new int[n];

int[] score = new int[n];

for(int i = 0;i
rating[i] = scan.nextInt();

score[i] = 1;

}

for(int i=0;i
if(rating[i]
score[i+1] = score[i] + 1;

}

}

for(int i=n-1;i>0;i--){

if(rating[i]
score[i-1] = Math.max(score[i-1],score[i]+1);

}

}

long sum = 0;

for(int i=0;i
sum +=score[i];

}

System.out.println(sum);

}

}




Alice code