結果
| 問題 | No.365 ジェンガソート | 
| コンテスト | |
| ユーザー |  jp_ste | 
| 提出日時 | 2016-05-09 21:06:05 | 
| 言語 | Java (openjdk 23) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 602 ms / 2,000 ms | 
| コード長 | 869 bytes | 
| コンパイル時間 | 2,021 ms | 
| コンパイル使用メモリ | 74,648 KB | 
| 実行使用メモリ | 59,620 KB | 
| 最終ジャッジ日時 | 2024-10-12 02:16:16 | 
| 合計ジャッジ時間 | 17,589 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 41 | 
ソースコード
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        try (Scanner scan = new Scanner(System.in)) {
            int n = scan.nextInt();
            int list[] = new int[n];
            for(int i=0; i<n; i++) {
                list[i] = scan.nextInt();
            }
            
            int max = list[0];
            int index = 0;
            for(int i=0; i<n; i++) {
                if(max < list[i]) {
                    max = list[i];
                    index = i;
                }
            }
            
            int target = max;
            int count = 0;
            for(int i=index; i>=0; i--) {
                if(list[i] == target) { 
                    count++;
                    target--;
                }
            }
            
            System.out.println(n-count);
        }
    }
}
            
            
            
        