結果
問題 | No.29 パワーアップ |
ユーザー |
|
提出日時 | 2021-02-17 23:37:25 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 146 ms / 5,000 ms |
コード長 | 888 bytes |
コンパイル時間 | 4,209 ms |
コンパイル使用メモリ | 83,100 KB |
実行使用メモリ | 41,428 KB |
最終ジャッジ日時 | 2024-09-14 08:21:47 |
合計ジャッジ時間 | 7,960 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 22 |
ソースコード
import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; import java.util.Scanner; import java.util.stream.Stream; public class No00000029_Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); Map<Integer, Integer> cntMap = new HashMap<Integer, Integer>(); int n = Integer.parseInt(scan.nextLine()); for(int i = 0; i < n; i++) { int[] arr = Stream.of(scan.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray(); for(int num : arr) { if(cntMap.containsKey(num)) { cntMap.put(num, cntMap.get(num) + 1); } else { cntMap.put(num, 1); } } } int sameCnt = 0; int anyCnt = 0; for(Entry<Integer, Integer> entry : cntMap.entrySet()) { int cnt = entry.getValue(); sameCnt += cnt / 2; anyCnt += cnt % 2; } System.out.println(sameCnt + anyCnt / 4); scan.close(); } }