結果

問題 No.806 木を道に
ユーザー mencottonmencotton
提出日時 2020-11-02 22:16:47
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 53 ms / 2,000 ms
コード長 375 bytes
コンパイル時間 663 ms
コンパイル使用メモリ 72,316 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-22 08:10:10
合計ジャッジ時間 2,125 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n - 1; i++) {
        int u, v;
        cin >> u >> v;
        a[u - 1]++, a[v - 1]++;
    }

    int ret = 0;
    for (int i = 0; i < n; i++) ret += max(0, a[i] - 2);

    cout << ret << endl;
    return 0;
}
0