35332023-02-28 18:53:03HorakZsofiÁtvágás (75 pont)cpp11Partially correct 71/75137ms5652 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;
}
SubtaskSumTestVerdictTimeMemory
base71/75
1Accepted0/03ms1816 KiB
2Accepted0/03ms2064 KiB
3Accepted0/08ms2464 KiB
4Accepted4/43ms2608 KiB
5Accepted4/42ms2636 KiB
6Accepted4/43ms2888 KiB
7Accepted4/43ms2976 KiB
8Partially correct2/43ms3188 KiB
9Partially correct2/43ms3184 KiB
10Accepted4/4107ms4536 KiB
11Accepted4/4119ms4536 KiB
12Accepted4/4131ms4664 KiB
13Accepted4/4136ms4848 KiB
14Accepted4/4136ms5216 KiB
15Accepted4/4136ms5080 KiB
16Accepted4/4136ms5152 KiB
17Accepted4/4137ms5280 KiB
18Accepted5/5136ms5372 KiB
19Accepted6/6136ms5440 KiB
20Accepted6/6136ms5652 KiB
21Accepted2/22ms4300 KiB