30552023-02-09 18:33:01xxxÁtvágás (75 pont)cpp14Partially correct 71/75140ms5856 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
base71/75
1Accepted0/03ms2156 KiB
2Accepted0/03ms2216 KiB
3Accepted0/08ms2380 KiB
4Accepted4/43ms2548 KiB
5Accepted4/43ms2728 KiB
6Accepted4/43ms2932 KiB
7Accepted4/43ms3128 KiB
8Partially correct2/43ms3216 KiB
9Partially correct2/43ms3336 KiB
10Accepted4/4108ms5016 KiB
11Accepted4/4120ms5380 KiB
12Accepted4/4136ms5336 KiB
13Accepted4/4136ms5400 KiB
14Accepted4/4137ms5500 KiB
15Accepted4/4136ms5604 KiB
16Accepted4/4136ms5724 KiB
17Accepted4/4140ms5640 KiB
18Accepted5/5136ms5616 KiB
19Accepted6/6136ms5856 KiB
20Accepted6/6136ms5832 KiB
21Accepted2/22ms4288 KiB