結果
| 問題 |
No.806 木を道に
|
| コンテスト | |
| ユーザー |
Beat7501
|
| 提出日時 | 2019-03-22 21:51:34 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 503 bytes |
| コンパイル時間 | 3,042 ms |
| コンパイル使用メモリ | 74,940 KB |
| 実行使用メモリ | 77,028 KB |
| 最終ジャッジ日時 | 2024-09-19 05:14:17 |
| 合計ジャッジ時間 | 11,408 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 1 WA * 9 TLE * 1 -- * 16 |
ソースコード
import java.util.*;
class Main{
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int k[] = new int[n];
for(int i = 1; i <= n-1; i++){
k[sc.nextInt()-1]++;
k[sc.nextInt()-1]++;
}
Arrays.sort(k);
int ans = 0;
for(int i = 2; i < n-1; i++){
if(k[i] < 2){
for(int j = i+1; j < n; j++){
if(k[j] > 2){
k[i]++;
k[j]++;
ans++;
}
}
Arrays.sort(k);
i=1;
}
}
System.out.print(ans);
}
}
Beat7501