35522023-02-28 21:29:32Zoli9Átvágás (75 pont)cpp17Accepted 75/75137ms5772 KiB
#include <bits/stdc++.h>
using namespace std;

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

cout<<szaml<<" "<<n-1-maxi << endl;
}
SubtaskSumTestVerdictTimeMemory
base75/75
1Accepted0/03ms1808 KiB
2Accepted0/03ms2020 KiB
3Accepted0/08ms2428 KiB
4Accepted4/43ms2568 KiB
5Accepted4/43ms2688 KiB
6Accepted4/43ms2904 KiB
7Accepted4/43ms3108 KiB
8Accepted4/43ms3200 KiB
9Accepted4/43ms3292 KiB
10Accepted4/4108ms4856 KiB
11Accepted4/4119ms4956 KiB
12Accepted4/4130ms5168 KiB
13Accepted4/4135ms5252 KiB
14Accepted4/4136ms5476 KiB
15Accepted4/4136ms5468 KiB
16Accepted4/4136ms5676 KiB
17Accepted4/4136ms5680 KiB
18Accepted5/5136ms5756 KiB
19Accepted6/6137ms5676 KiB
20Accepted6/6136ms5772 KiB
21Accepted2/23ms4324 KiB