結果

問題 No.806 木を道に
コンテスト
ユーザー WarToks
提出日時 2019-04-04 23:30:44
言語 Scala(Beta)
(3.8.1)
コンパイル:
scalac _filename_
実行:
java -cp .:/home/linuxbrew/.linuxbrew/Cellar/scala/3.8.1/libexec/maven2/org/scala-lang/scala3-library_3/3.8.1/scala3-library_3-3.8.1.jar:/home/linuxbrew/.linuxbrew/Cellar/scala/3.8.1/libexec/maven2/org/scala-lang/scala-library/3.8.1/scala-library-3.8.1.jar _class_
結果
AC  
実行時間 532 ms / 2,000 ms
コード長 487 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 10,903 ms
コンパイル使用メモリ 269,796 KB
実行使用メモリ 71,740 KB
最終ジャッジ日時 2026-03-09 16:44:55
合計ジャッジ時間 21,253 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import scala.io.StdIn._

object Main{
    def main(args: Array[String]): Unit ={
        val n : Int = readLine().toInt
        val degrees : Array[Int] = Array.fill(n)(0)
        for(_ <- 1 until n){
            val Array(a, b) : Array[Int] = readLine().split(' ').map(_.toInt)
            degrees(a-1) += 1
            degrees(b-1) += 1
        }
        var ans : Int = 0
        for(i <- 0 until n){
            ans += math.max(0, degrees(i)-2)
        }
        println(ans)
    }
}
0