結果

問題 No.365 ジェンガソート
ユーザー spaciaspacia
提出日時 2016-06-03 11:25:36
言語 Java21
(openjdk 21)
結果
AC  
実行時間 596 ms / 2,000 ms
コード長 508 bytes
コンパイル時間 2,260 ms
コンパイル使用メモリ 74,392 KB
実行使用メモリ 59,824 KB
最終ジャッジ日時 2024-04-20 07:13:14
合計ジャッジ時間 17,387 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
53,960 KB
testcase_01 AC 125 ms
53,980 KB
testcase_02 AC 126 ms
53,816 KB
testcase_03 AC 124 ms
54,156 KB
testcase_04 AC 123 ms
54,164 KB
testcase_05 AC 128 ms
54,276 KB
testcase_06 AC 131 ms
54,136 KB
testcase_07 AC 125 ms
54,184 KB
testcase_08 AC 129 ms
54,120 KB
testcase_09 AC 128 ms
54,144 KB
testcase_10 AC 130 ms
54,260 KB
testcase_11 AC 127 ms
54,328 KB
testcase_12 AC 130 ms
54,368 KB
testcase_13 AC 131 ms
54,412 KB
testcase_14 AC 115 ms
53,132 KB
testcase_15 AC 134 ms
53,928 KB
testcase_16 AC 535 ms
59,488 KB
testcase_17 AC 480 ms
58,680 KB
testcase_18 AC 241 ms
57,892 KB
testcase_19 AC 519 ms
59,468 KB
testcase_20 AC 352 ms
58,888 KB
testcase_21 AC 348 ms
58,936 KB
testcase_22 AC 560 ms
59,256 KB
testcase_23 AC 433 ms
59,340 KB
testcase_24 AC 558 ms
59,452 KB
testcase_25 AC 336 ms
58,944 KB
testcase_26 AC 522 ms
59,288 KB
testcase_27 AC 586 ms
59,420 KB
testcase_28 AC 498 ms
59,488 KB
testcase_29 AC 573 ms
59,476 KB
testcase_30 AC 517 ms
59,472 KB
testcase_31 AC 364 ms
58,932 KB
testcase_32 AC 376 ms
59,132 KB
testcase_33 AC 596 ms
59,624 KB
testcase_34 AC 298 ms
58,752 KB
testcase_35 AC 520 ms
59,352 KB
testcase_36 AC 500 ms
59,048 KB
testcase_37 AC 499 ms
59,128 KB
testcase_38 AC 561 ms
59,308 KB
testcase_39 AC 562 ms
59,824 KB
testcase_40 AC 582 ms
59,576 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {

	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int[] nums = new int[n];
		int[] pos  = new int[n + 1];

		for (int i = 0; i < n; i++) {
			nums[i] = sc.nextInt();
			pos[nums[i]] = i;
		}

		System.out.println(solve(nums, pos));

		sc.close();
	}

	public static int solve (int[] nums, int[] pos) {
		for (int i = nums.length; i > 1; i--)
			if (pos[i] < pos[i - 1]) return i - 1;
		return 0;
	}

}
0