結果
| 問題 | No.29 パワーアップ |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-02-17 23:37:25 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 144 ms / 5,000 ms |
| コード長 | 888 bytes |
| 記録 | |
| コンパイル時間 | 4,332 ms |
| コンパイル使用メモリ | 90,264 KB |
| 実行使用メモリ | 46,900 KB |
| 最終ジャッジ日時 | 2025-10-24 21:17:00 |
| 合計ジャッジ時間 | 7,698 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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();
}
}