89392024-02-06 13:48:21IgnácÁtvágás (75 pont)cpp14Accepted 75/75137ms30904 KiB
// Source: https://usaco.guide/general/io

#include <bits/stdc++.h>
#include <vector>
using namespace std;

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

	int maxi = 0, db = 0;
	for (int i = 0; i < n; i++) {
		if (c[i] > maxi) maxi = c[i];
		if (c[i] == 1) db++;
	}

	cout << db - 2 << " " << n - maxi - 1;
}
SubtaskSumTestVerdictTimeMemory
base75/75
1Accepted0/03ms1812 KiB
2Accepted0/03ms2088 KiB
3Accepted0/08ms2256 KiB
4Accepted4/43ms2420 KiB
5Accepted4/43ms2608 KiB
6Accepted4/43ms2828 KiB
7Accepted4/42ms2912 KiB
8Accepted4/43ms2920 KiB
9Accepted4/43ms2928 KiB
10Accepted4/4108ms5948 KiB
11Accepted4/4119ms8064 KiB
12Accepted4/4133ms10340 KiB
13Accepted4/4136ms13000 KiB
14Accepted4/4137ms15896 KiB
15Accepted4/4137ms18512 KiB
16Accepted4/4137ms20908 KiB
17Accepted4/4137ms23440 KiB
18Accepted5/5137ms25976 KiB
19Accepted6/6137ms28392 KiB
20Accepted6/6137ms30904 KiB
21Accepted2/23ms29640 KiB