Submission #1305934


Source Code Expand

import java.io.*;

public class Main {
    public static void main(String[] args) {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        try {
            int n = Integer.parseInt(in.readLine());
            String[] an = in.readLine().split(" ");
            int[] list = new int[n];
            for (int i = 0; i < an.length; ++i) {
                list[i] = Integer.parseInt(an[i]);
            }

            long sum = 0;
            for (int l = 0; l < n; ++l) {
                long sum1 = 0;
                for (int r = l; r < n; ++r) {
                    sum1 += min(list, l, r);
                }
                sum += sum1;
            }
            System.out.println(sum);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    private static int min(int[] list, int l, int r) {
        int min = list[l];
        for (int i = l + 1; i <= r; ++i) {
            if (list[i] < min) {
                min = list[i];
            }
        }
        return min; 
    }
}

Submission Info

Submission Time
Task B - Minimum Sum
User unirita135
Language Java8 (OpenJDK 1.8.0)
Score 0
Code Size 1085 Byte
Status TLE
Exec Time 2113 ms
Memory 47828 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 2105 ms 46036 KB
corner1 TLE 2108 ms 47828 KB
corner2 AC 66 ms 21332 KB
corner3 TLE 2113 ms 43036 KB
example0 AC 68 ms 19924 KB
example1 AC 69 ms 19668 KB
example2 AC 67 ms 21332 KB
maxrand0 TLE 2109 ms 44996 KB
maxrand1 TLE 2109 ms 46036 KB
maxrand2 TLE 2105 ms 46428 KB
rand0 AC 78 ms 19284 KB
rand1 AC 68 ms 18516 KB
rand2 AC 79 ms 20948 KB