結果

問題 No.2036 Max Middle
ユーザー tentententen
提出日時 2023-12-07 10:34:39
言語 Java21
(openjdk 21)
結果
AC  
実行時間 292 ms / 2,000 ms
コード長 1,830 bytes
コンパイル時間 3,939 ms
コンパイル使用メモリ 89,900 KB
実行使用メモリ 66,712 KB
最終ジャッジ日時 2023-12-07 10:34:49
合計ジャッジ時間 9,794 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
53,988 KB
testcase_01 AC 54 ms
53,992 KB
testcase_02 AC 53 ms
54,000 KB
testcase_03 AC 53 ms
53,996 KB
testcase_04 AC 53 ms
53,980 KB
testcase_05 AC 77 ms
53,988 KB
testcase_06 AC 54 ms
51,904 KB
testcase_07 AC 54 ms
53,988 KB
testcase_08 AC 235 ms
61,640 KB
testcase_09 AC 264 ms
64,108 KB
testcase_10 AC 279 ms
64,288 KB
testcase_11 AC 259 ms
62,456 KB
testcase_12 AC 264 ms
59,444 KB
testcase_13 AC 289 ms
66,148 KB
testcase_14 AC 116 ms
55,408 KB
testcase_15 AC 74 ms
54,772 KB
testcase_16 AC 285 ms
66,712 KB
testcase_17 AC 191 ms
59,568 KB
testcase_18 AC 255 ms
61,424 KB
testcase_19 AC 256 ms
61,424 KB
testcase_20 AC 292 ms
62,604 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        int[] values = new int[n];
        for (int i = 0; i < n; i++) {
            values[i] = sc.nextInt();
        }
        int count = 0;
        long ans = 0;
        for (int i = 0; i < n - 1; i++) {
            if (values[i] < values[i + 1]) {
                count++;
            } else {
                ans += count;
            }
        }
        System.out.println(ans);
    }
}
class Utilities {
    static String arrayToLineString(Object[] arr) {
        return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n"));
    }
    
    static String arrayToLineString(int[] arr) {
        return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new));
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public int[] nextIntArray() throws Exception {
        return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    
}
0