結果
| 問題 | No.29 パワーアップ |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-04-22 14:18:59 |
| 言語 | Java (openjdk 25.0.2) |
| 結果 |
AC
|
| 実行時間 | 81 ms / 5,000 ms |
| + 954µs | |
| コード長 | 1,401 bytes |
| 記録 | |
| コンパイル時間 | 1,691 ms |
| コンパイル使用メモリ | 103,064 KB |
| 実行使用メモリ | 44,472 KB |
| 最終ジャッジ日時 | 2026-07-15 21:28:00 |
| 合計ジャッジ時間 | 4,768 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 22 |
ソースコード
import java.util.*;
import java.util.stream.*;
import static java.lang.Math.*;
// (ΦωΦ)<何事もやりすぎはよくない
public class Main {
private void solve() {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
sc.nextLine();
List<List<Integer>> lines = IntStream.range(0, n)
.mapToObj(i -> Stream.of(sc.nextLine().split(" "))
.map(Integer::valueOf)
.collect(Collectors.toList()))
.collect(Collectors.toList());
List<Integer> flattened = lines.stream().flatMap(List::stream).collect(Collectors.toList());
Set<Integer> sett = new HashSet<>(flattened);
List<Integer> values = sett.stream()
.map(e -> Collections.frequency(flattened, e))
.collect(Collectors.toList());
long res = values.stream()
.map(e -> e/2)
.reduce(0, (x, y) -> x + y) +
values.stream()
.filter(e -> e%2==1)
.count() / 4;
System.out.println(res);
}
public static void main(String[] args) {
new Main().solve();
}
}