35512023-02-28 21:29:29HorakZsofiÁtvágás (75 pont)cpp11Accepted 75/75142ms5224 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; i++){
	if(fszam[i]>2){
		szaml+=fszam[i]-2;
	}
	if(maxi<fszam[i]){
		maxi=fszam[i];
	}
}

cout<<szaml<<" "<<n-1-maxi << '\n';
}
SubtaskSumTestVerdictTimeMemory
base75/75
1Accepted0/03ms1808 KiB
2Accepted0/03ms2004 KiB
3Accepted0/08ms2416 KiB
4Accepted4/43ms2296 KiB
5Accepted4/43ms2300 KiB
6Accepted4/43ms2432 KiB
7Accepted4/43ms2644 KiB
8Accepted4/43ms2724 KiB
9Accepted4/43ms2752 KiB
10Accepted4/4107ms4356 KiB
11Accepted4/4115ms4476 KiB
12Accepted4/4129ms4556 KiB
13Accepted4/4142ms4684 KiB
14Accepted4/4133ms4768 KiB
15Accepted4/4133ms4948 KiB
16Accepted4/4135ms4948 KiB
17Accepted4/4134ms5012 KiB
18Accepted5/5133ms5008 KiB
19Accepted6/6133ms5012 KiB
20Accepted6/6133ms5224 KiB
21Accepted2/23ms3948 KiB