結果
問題 | No.921 ずんだアロー |
ユーザー |
![]() |
提出日時 | 2019-11-08 22:05:02 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 222 ms / 2,000 ms |
コード長 | 656 bytes |
コンパイル時間 | 2,574 ms |
コンパイル使用メモリ | 73,064 KB |
実行使用メモリ | 48,708 KB |
最終ジャッジ日時 | 2024-09-15 01:30:13 |
合計ジャッジ時間 | 6,686 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
import java.io.BufferedReader; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); String[] sa = br.readLine().split(" "); int[] a = new int[n]; for (int i = 0; i < n; i++) { a[i] = Integer.parseInt(sa[i]); } br.close(); int ans = 1; boolean flg = true; for (int i = 1; i < n; i++) { if (flg) { if (a[i] == a[i - 1]) { ans++; } else { flg = false; } } else { ans++; flg = true; } } System.out.println(ans); } }