結果
問題 |
No.112 ややこしい鶴亀算
|
ユーザー |
![]() |
提出日時 | 2020-11-05 18:53:40 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 161 ms / 5,000 ms |
コード長 | 657 bytes |
コンパイル時間 | 2,692 ms |
コンパイル使用メモリ | 76,988 KB |
実行使用メモリ | 42,656 KB |
最終ジャッジ日時 | 2024-07-22 11:17:34 |
合計ジャッジ時間 | 7,136 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 23 |
ソースコード
import java.util.*; public class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); TreeMap<Integer, Integer> map = new TreeMap<>(); for (int i = 0; i < n; i++) { int x = sc.nextInt(); map.put(x, map.getOrDefault(x, 0) + 1); } int bird; int turtle; if (map.size() == 1) { if (map.firstKey() / (n - 1) == 2) { bird = n; turtle = 0; } else { bird = 0; turtle = n; } } else { bird = map.lastEntry().getValue(); turtle = map.firstEntry().getValue(); } System.out.println(bird + " " + turtle); } }