結果

問題 No.742 にゃんにゃんにゃん 猫の挨拶
ユーザー htensaihtensai
提出日時 2020-02-17 12:31:28
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,925 ms / 2,500 ms
コード長 661 bytes
コンパイル時間 2,245 ms
コンパイル使用メモリ 74,672 KB
実行使用メモリ 41,484 KB
最終ジャッジ日時 2024-04-16 03:48:42
合計ジャッジ時間 6,256 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
36,632 KB
testcase_01 AC 55 ms
36,976 KB
testcase_02 AC 55 ms
37,152 KB
testcase_03 AC 55 ms
36,844 KB
testcase_04 AC 56 ms
36,932 KB
testcase_05 AC 58 ms
36,624 KB
testcase_06 AC 62 ms
37,084 KB
testcase_07 AC 92 ms
38,156 KB
testcase_08 AC 103 ms
38,916 KB
testcase_09 AC 53 ms
37,084 KB
testcase_10 AC 54 ms
36,516 KB
testcase_11 AC 1,925 ms
41,484 KB
testcase_12 AC 543 ms
41,312 KB
testcase_13 AC 55 ms
36,788 KB
testcase_14 AC 55 ms
37,000 KB
testcase_15 AC 55 ms
36,904 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
	public static void main (String[] args) throws Exception {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) {
		    arr[i] = Integer.parseInt(br.readLine());
		}
		int count = 0;
		for (int i = n - 1; i >= 0; i--) {
		    for (int j = 0; j < i; j++) {
		        if (arr[j] > arr[j + 1]) {
		            count++;
		            int tmp = arr[j];
		            arr[j] = arr[j + 1];
		            arr[j + 1] = tmp;
		        }
		    }
		}
		System.out.println(count);
    }
}
0