30562023-02-09 18:35:12xxxÁtvágás (75 pont)cpp14Accepted 75/75138ms6124 KiB
#include <bits/stdc++.h>
#include <vector>
using namespace std;

int main() {
    int n;
    cin >> n;
    int v[n+1] = {0};
    int a, b;
    for (int i = 1; i < n; i++) {
        cin >> a >> b;
        v[a]++;
        v[b]++;
    }

    int max = 0, ans = 0;
    for (int i = 1; i <= n; i++) {
        if (max < v[i])
            max = v[i];
        if (v[i] > 2)
            ans += v[i] - 2;
    }

    cout << ans << " " << n - max - 1 << endl;


    return 0;

}
SubtaskSumTestVerdictTimeMemory
base75/75
1Accepted0/03ms1912 KiB
2Accepted0/03ms2300 KiB
3Accepted0/08ms2620 KiB
4Accepted4/43ms2460 KiB
5Accepted4/43ms2616 KiB
6Accepted4/43ms2828 KiB
7Accepted4/43ms2992 KiB
8Accepted4/43ms3200 KiB
9Accepted4/43ms3280 KiB
10Accepted4/4108ms4948 KiB
11Accepted4/4120ms5176 KiB
12Accepted4/4134ms5264 KiB
13Accepted4/4137ms5520 KiB
14Accepted4/4137ms5584 KiB
15Accepted4/4137ms5660 KiB
16Accepted4/4137ms5844 KiB
17Accepted4/4137ms5804 KiB
18Accepted5/5137ms5784 KiB
19Accepted6/6137ms5916 KiB
20Accepted6/6138ms6124 KiB
21Accepted2/23ms4668 KiB