結果
問題 |
No.365 ジェンガソート
|
ユーザー |
![]() |
提出日時 | 2017-09-27 14:28:22 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 546 bytes |
コンパイル時間 | 6,828 ms |
コンパイル使用メモリ | 76,172 KB |
実行使用メモリ | 63,436 KB |
最終ジャッジ日時 | 2024-11-15 17:37:17 |
合計ジャッジ時間 | 22,101 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 WA * 22 |
ソースコード
import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class JengaSort { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); List<Integer> list = new ArrayList<Integer>(); for (int i = 0; i < N; i++) { list.add(sc.nextInt()); } int base = list.get(N - 1); int count = 0; for (int i = N-1; i > 0; i--) { int next = list.get(i - 1); if (next == base - 1) { base = next; } else { count++; } } System.out.println(count); } }