結果
問題 |
No.112 ややこしい鶴亀算
|
ユーザー |
![]() |
提出日時 | 2020-11-05 18:52:32 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 657 bytes |
コンパイル時間 | 4,221 ms |
コンパイル使用メモリ | 76,616 KB |
実行使用メモリ | 58,620 KB |
最終ジャッジ日時 | 2024-07-22 11:17:22 |
合計ジャッジ時間 | 9,253 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 11 WA * 12 |
ソースコード
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.firstEntry().getValue(); turtle = map.lastEntry().getValue(); } System.out.println(bird + " " + turtle); } }