10162022-02-23 18:01:41CzDaniÁtvágás (75 pont)cpp14Accepted 75/75150ms29520 KiB
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
	int n, ans1 = 0, maxi = 0;
	cin >> n;
	vector<int> v(n + 1);
	for (int i = 1; i < n; i++) {
		int a, b;
		cin >> a >> b;
		v[a]++;
		v[b]++;
	}
	for (int i = 1; i <= n; i++) {
		if (v[i] > 2) {
			ans1 += v[i] - 2;
		}
		maxi = max(maxi, v[i]);
	}
	cout << ans1 << '\n' << n - maxi - 1;
}
SubtaskSumTestVerdictTimeMemory
base75/75
1Accepted0/02ms1736 KiB
2Accepted0/01ms1780 KiB
3Accepted0/07ms2016 KiB
4Accepted4/41ms1944 KiB
5Accepted4/41ms1940 KiB
6Accepted4/41ms1944 KiB
7Accepted4/41ms1960 KiB
8Accepted4/41ms1956 KiB
9Accepted4/41ms1964 KiB
10Accepted4/4101ms5020 KiB
11Accepted4/4116ms6940 KiB
12Accepted4/4130ms9320 KiB
13Accepted4/4129ms11852 KiB
14Accepted4/4130ms14376 KiB
15Accepted4/4150ms16892 KiB
16Accepted4/4126ms19424 KiB
17Accepted4/4126ms21944 KiB
18Accepted5/5123ms24472 KiB
19Accepted6/6126ms26996 KiB
20Accepted6/6130ms29520 KiB
21Accepted2/21ms28232 KiB