35502023-02-28 21:20:36Zoli9Átvágás (75 pont)cpp17Partially correct 71/75140ms4748 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 << endl;
}
SubtaskSumTestVerdictTimeMemory
base71/75
1Accepted0/03ms1808 KiB
2Accepted0/03ms2004 KiB
3Accepted0/08ms2124 KiB
4Accepted4/43ms2216 KiB
5Accepted4/43ms2360 KiB
6Accepted4/43ms2580 KiB
7Accepted4/43ms2612 KiB
8Partially correct2/42ms2628 KiB
9Partially correct2/43ms2756 KiB
10Accepted4/4107ms4192 KiB
11Accepted4/4120ms4316 KiB
12Accepted4/4131ms4552 KiB
13Accepted4/4135ms4516 KiB
14Accepted4/4135ms4512 KiB
15Accepted4/4136ms4476 KiB
16Accepted4/4140ms4748 KiB
17Accepted4/4136ms4624 KiB
18Accepted5/5136ms4620 KiB
19Accepted6/6135ms4624 KiB
20Accepted6/6135ms4688 KiB
21Accepted2/23ms3416 KiB