35482023-02-28 21:16:58Zoli9Átvágás (75 pont)cpp17Partially correct 71/75138ms5396 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
base71/75
1Accepted0/03ms2000 KiB
2Accepted0/03ms2140 KiB
3Accepted0/08ms2556 KiB
4Accepted4/43ms2468 KiB
5Accepted4/43ms2600 KiB
6Accepted4/43ms2556 KiB
7Accepted4/43ms2552 KiB
8Partially correct2/43ms2684 KiB
9Partially correct2/43ms2896 KiB
10Accepted4/4108ms4460 KiB
11Accepted4/4119ms4552 KiB
12Accepted4/4134ms4680 KiB
13Accepted4/4136ms4760 KiB
14Accepted4/4136ms5032 KiB
15Accepted4/4136ms5104 KiB
16Accepted4/4138ms5104 KiB
17Accepted4/4136ms4992 KiB
18Accepted5/5136ms5120 KiB
19Accepted6/6137ms5120 KiB
20Accepted6/6136ms5396 KiB
21Accepted2/23ms3952 KiB