Submission #2234383


Source Code Expand

import java.util.Scanner;
import java.util.TreeSet;

public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		int[] rev = new int[n+1];
		for(int i = 0; i < n; i++) {
			arr[i] = sc.nextInt();
			rev[arr[i]] = i;
		}

		long count = 0;

		TreeSet<Integer> sorted = new TreeSet<>();
		for(int under = 0; under < n; under++) {
			for(int upper = under; upper < n; upper++) {
				int min = n+1;
				for(int i = under; i <= upper; i++) {
					min = Math.min(min, arr[i]);
				}
				count+=min;
			}
		}
		System.out.println(count);
	}
}

Submission Info

Submission Time
Task B - Minimum Sum
User naoppy
Language Java8 (OpenJDK 1.8.0)
Score 0
Code Size 664 Byte
Status TLE
Exec Time 2109 ms
Memory 67728 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 400
Status
AC × 3
AC × 7
TLE × 6
Set Name Test Cases
Sample example0, example1, example2
All corner0, corner1, corner2, corner3, example0, example1, example2, maxrand0, maxrand1, maxrand2, rand0, rand1, rand2
Case Name Status Exec Time Memory
corner0 TLE 2109 ms 67728 KB
corner1 TLE 2109 ms 62208 KB
corner2 AC 91 ms 20948 KB
corner3 TLE 2109 ms 62936 KB
example0 AC 92 ms 20820 KB
example1 AC 92 ms 20564 KB
example2 AC 92 ms 19796 KB
maxrand0 TLE 2109 ms 60984 KB
maxrand1 TLE 2109 ms 63624 KB
maxrand2 TLE 2109 ms 61632 KB
rand0 AC 115 ms 21076 KB
rand1 AC 93 ms 18772 KB
rand2 AC 101 ms 17748 KB