結果
問題 | No.365 ジェンガソート |
ユーザー | ki_ki33 |
提出日時 | 2016-04-29 22:33:43 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 617 ms / 2,000 ms |
コード長 | 691 bytes |
コンパイル時間 | 2,319 ms |
コンパイル使用メモリ | 74,552 KB |
実行使用メモリ | 48,468 KB |
最終ジャッジ日時 | 2024-10-12 01:39:44 |
合計ジャッジ時間 | 17,793 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 41 |
ソースコード
import java.io.BufferedInputStream; import java.util.Scanner; public class Main { static final long C = 1000000007; static final int CY = 1000000000; StringBuilder sb; public void calc() { sb = new StringBuilder(); BufferedInputStream bs = new BufferedInputStream(System.in); Scanner sc = new Scanner(bs); int n = sc.nextInt(); int[] a = new int[n]; for (int i=0; i < n; i++) { a[i] = sc.nextInt(); } long ans = 0; int bef = n+1; for (int i=n-1; i >= 0; i--) { if (bef-1 != a[i]) { ans++; }else { bef = a[i]; } } System.out.println(ans); } public static void main(String[] args) { Main main = new Main(); main.calc(); } }