結果

問題 No.365 ジェンガソート
ユーザー YamaKasa
提出日時 2018-09-18 23:07:33
言語 Java
(openjdk 23)
結果
AC  
実行時間 530 ms / 2,000 ms
コード長 412 bytes
コンパイル時間 1,917 ms
コンパイル使用メモリ 73,944 KB
実行使用メモリ 59,740 KB
最終ジャッジ日時 2024-07-18 08:08:12
合計ジャッジ時間 16,182 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int []a = new int[N];
		for(int i = 0; i < N; i++) {
			a[i] = scan.nextInt();
		}
		scan.close();
		int k = N;
		int cnt = 0;
		for(int i = N - 1; i >= 0; i--) {
			if(a[i] == k) {
				k--;
			}else {
				cnt++;
			}
		}
		System.out.println(cnt);
	}
}
0