結果
| 問題 |
No.806 木を道に
|
| コンテスト | |
| ユーザー |
htensai
|
| 提出日時 | 2020-06-10 13:58:35 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 692 ms / 2,000 ms |
| コード長 | 451 bytes |
| コンパイル時間 | 2,305 ms |
| コンパイル使用メモリ | 77,796 KB |
| 実行使用メモリ | 53,124 KB |
| 最終ジャッジ日時 | 2024-06-23 04:00:16 |
| 合計ジャッジ時間 | 13,922 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 27 |
ソースコード
import java.util.*;
public class Main {
public static void main (String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] counts = new int[n];
for (int i = 0; i < n - 1; i++) {
int a = sc.nextInt() - 1;
int b = sc.nextInt() - 1;
counts[a]++;
counts[b]++;
}
int total = 0;
for (int x : counts) {
if (x > 2) {
total += x - 2;
}
}
System.out.println(total);
}
}
htensai