結果

問題 No.806 木を道に
ユーザー Mcpu3
提出日時 2019-03-22 22:07:54
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 53 ms / 2,000 ms
コード長 390 bytes
コンパイル時間 682 ms
コンパイル使用メモリ 71,912 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-19 05:32:11
合計ジャッジ時間 2,254 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int> tmp1(N);
	for (int i = 0; i < N - 1; ++i) {
		int a, b;
		cin >> a >> b;
		++tmp1[a - 1];
		++tmp1[b - 1];
	}
	int tmp2 = 0, tmp3 = 0;
	for (int& i : tmp1) {
		if (i == 0) ++tmp2;
		else if (i > 2) tmp3 += i - 2;
	}
	cout << max(tmp2, tmp3);
}
0