Submission #905777


Source Code Expand

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        long sum = 0;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            sum += a[i];
        }
        for (int d = 1; d < n; d++) {
            int[] b = new int[n - d];
            for (int i = 0; i < n - d; i++) {
                b[i] = Math.min(a[i], a[i + 1]);
                sum += b[i];
            }
            a = b;
        }
        System.out.println(sum);
    }
}

Submission Info

Submission Time
Task B - Minimum Sum
User elzup
Language Java8 (OpenJDK 1.8.0)
Score 0
Code Size 630 Byte
Status TLE
Exec Time 2121 ms
Memory 333896 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 2120 ms 332284 KB
corner1 TLE 2120 ms 333420 KB
corner2 AC 126 ms 9680 KB
corner3 TLE 2120 ms 333120 KB
example0 AC 127 ms 9680 KB
example1 AC 127 ms 9552 KB
example2 AC 127 ms 9676 KB
maxrand0 TLE 2120 ms 332912 KB
maxrand1 TLE 2120 ms 333444 KB
maxrand2 TLE 2121 ms 333896 KB
rand0 AC 144 ms 10452 KB
rand1 AC 126 ms 9680 KB
rand2 AC 131 ms 9680 KB