답안 #170347

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
170347 2019-12-24T20:22:07 Z ngmh Company Planning (TOKI14_company) C++11
100 / 100
280 ms 14372 KB
#include <bits/stdc++.h>
using namespace std;

int n, m, mini, maxi, medi, t;
vector<int> adj[100005];

int yeets(int x, int k){
    if(adj[x].size() == 0) return 1;
    priority_queue<int> cs;
    for(auto it : adj[x]) cs.push(yeets(it, k));
    int t = 0;
    for(int i = 1; i <= k; i++){
        if(cs.size() == 0) break;
        t += cs.top(); cs.pop();
    }
    return t+1;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    if(m == 1){ cout << 0; return 0; }
    for(int i = 2; i <= n; i++){ cin >> t; adj[t].push_back(i); }
    mini = 1; maxi = n;
    while(mini < maxi){
        medi = mini+(maxi-mini)/2;
        if(yeets(1, medi) >= m) maxi = medi;
        else mini = medi+1;
    }
    cout << mini;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 4 ms 2808 KB Output is correct
3 Correct 4 ms 2680 KB Output is correct
4 Correct 4 ms 2680 KB Output is correct
5 Correct 5 ms 2680 KB Output is correct
6 Correct 4 ms 2680 KB Output is correct
7 Correct 5 ms 2680 KB Output is correct
8 Correct 5 ms 2680 KB Output is correct
9 Correct 4 ms 2680 KB Output is correct
10 Correct 4 ms 2680 KB Output is correct
11 Correct 4 ms 2680 KB Output is correct
12 Correct 4 ms 2680 KB Output is correct
13 Correct 4 ms 2680 KB Output is correct
14 Correct 4 ms 2684 KB Output is correct
15 Correct 4 ms 2680 KB Output is correct
16 Correct 4 ms 2680 KB Output is correct
17 Correct 4 ms 2680 KB Output is correct
18 Correct 4 ms 2680 KB Output is correct
19 Correct 4 ms 2832 KB Output is correct
20 Correct 4 ms 2680 KB Output is correct
21 Correct 4 ms 2680 KB Output is correct
22 Correct 4 ms 2680 KB Output is correct
23 Correct 4 ms 2680 KB Output is correct
24 Correct 4 ms 2680 KB Output is correct
25 Correct 4 ms 2680 KB Output is correct
26 Correct 4 ms 2760 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2808 KB Output is correct
2 Correct 5 ms 2684 KB Output is correct
3 Correct 5 ms 2808 KB Output is correct
4 Correct 5 ms 2808 KB Output is correct
5 Correct 5 ms 2680 KB Output is correct
6 Correct 4 ms 2680 KB Output is correct
7 Correct 4 ms 2684 KB Output is correct
8 Correct 4 ms 2680 KB Output is correct
9 Correct 4 ms 2680 KB Output is correct
10 Correct 4 ms 2680 KB Output is correct
11 Correct 4 ms 2680 KB Output is correct
12 Correct 4 ms 2680 KB Output is correct
13 Correct 4 ms 2680 KB Output is correct
14 Correct 5 ms 2680 KB Output is correct
15 Correct 4 ms 2680 KB Output is correct
16 Correct 4 ms 2680 KB Output is correct
17 Correct 5 ms 2684 KB Output is correct
18 Correct 5 ms 2680 KB Output is correct
19 Correct 4 ms 2680 KB Output is correct
20 Correct 5 ms 2684 KB Output is correct
21 Correct 5 ms 2808 KB Output is correct
22 Correct 5 ms 2808 KB Output is correct
23 Correct 5 ms 2808 KB Output is correct
24 Correct 4 ms 2680 KB Output is correct
25 Correct 5 ms 2680 KB Output is correct
26 Correct 4 ms 2680 KB Output is correct
27 Correct 4 ms 2680 KB Output is correct
28 Correct 4 ms 2760 KB Output is correct
29 Correct 4 ms 2680 KB Output is correct
30 Correct 4 ms 2680 KB Output is correct
31 Correct 4 ms 2680 KB Output is correct
32 Correct 4 ms 2680 KB Output is correct
33 Correct 4 ms 2680 KB Output is correct
34 Correct 4 ms 2680 KB Output is correct
35 Correct 4 ms 2680 KB Output is correct
36 Correct 4 ms 2680 KB Output is correct
37 Correct 4 ms 2684 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 216 ms 5240 KB Output is correct
3 Correct 120 ms 4984 KB Output is correct
4 Correct 120 ms 4856 KB Output is correct
5 Correct 207 ms 5372 KB Output is correct
6 Correct 184 ms 5112 KB Output is correct
7 Correct 177 ms 4984 KB Output is correct
8 Correct 168 ms 4856 KB Output is correct
9 Correct 172 ms 4984 KB Output is correct
10 Correct 151 ms 4748 KB Output is correct
11 Correct 189 ms 4880 KB Output is correct
12 Correct 280 ms 5280 KB Output is correct
13 Correct 201 ms 5240 KB Output is correct
14 Correct 110 ms 4344 KB Output is correct
15 Correct 190 ms 5112 KB Output is correct
16 Correct 115 ms 4344 KB Output is correct
17 Correct 161 ms 4780 KB Output is correct
18 Correct 84 ms 3832 KB Output is correct
19 Correct 48 ms 3576 KB Output is correct
20 Correct 100 ms 4472 KB Output is correct
21 Correct 69 ms 3960 KB Output is correct
22 Correct 30 ms 3192 KB Output is correct
23 Correct 99 ms 4472 KB Output is correct
24 Correct 112 ms 4728 KB Output is correct
25 Correct 4 ms 2680 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 68 ms 3684 KB Output is correct
3 Correct 79 ms 4244 KB Output is correct
4 Correct 143 ms 4984 KB Output is correct
5 Correct 130 ms 6264 KB Output is correct
6 Correct 121 ms 4960 KB Output is correct
7 Correct 145 ms 14276 KB Output is correct
8 Correct 234 ms 4984 KB Output is correct
9 Correct 199 ms 4984 KB Output is correct
10 Correct 280 ms 4728 KB Output is correct
11 Correct 63 ms 3576 KB Output is correct
12 Correct 162 ms 4856 KB Output is correct
13 Correct 116 ms 4216 KB Output is correct
14 Correct 166 ms 4728 KB Output is correct
15 Correct 191 ms 5112 KB Output is correct
16 Correct 92 ms 3960 KB Output is correct
17 Correct 84 ms 3704 KB Output is correct
18 Correct 140 ms 4476 KB Output is correct
19 Correct 184 ms 4600 KB Output is correct
20 Correct 74 ms 3836 KB Output is correct
21 Correct 44 ms 3320 KB Output is correct
22 Correct 58 ms 7800 KB Output is correct
23 Correct 78 ms 9720 KB Output is correct
24 Correct 79 ms 9592 KB Output is correct
25 Correct 62 ms 4600 KB Output is correct
26 Correct 107 ms 5888 KB Output is correct
27 Correct 118 ms 4856 KB Output is correct
28 Correct 74 ms 4088 KB Output is correct
29 Correct 103 ms 4556 KB Output is correct
30 Correct 105 ms 4344 KB Output is correct
31 Correct 128 ms 4472 KB Output is correct
32 Correct 42 ms 3320 KB Output is correct
33 Correct 30 ms 3412 KB Output is correct
34 Correct 30 ms 3172 KB Output is correct
35 Correct 9 ms 2844 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2808 KB Output is correct
2 Correct 38 ms 3608 KB Output is correct
3 Correct 70 ms 4236 KB Output is correct
4 Correct 173 ms 4856 KB Output is correct
5 Correct 129 ms 6392 KB Output is correct
6 Correct 138 ms 4856 KB Output is correct
7 Correct 144 ms 14372 KB Output is correct
8 Correct 205 ms 4984 KB Output is correct
9 Correct 67 ms 3956 KB Output is correct
10 Correct 80 ms 4280 KB Output is correct
11 Correct 160 ms 4856 KB Output is correct
12 Correct 134 ms 6396 KB Output is correct
13 Correct 125 ms 4916 KB Output is correct
14 Correct 140 ms 14280 KB Output is correct
15 Correct 233 ms 5112 KB Output is correct
16 Correct 215 ms 5116 KB Output is correct
17 Correct 206 ms 5112 KB Output is correct
18 Correct 190 ms 5112 KB Output is correct
19 Correct 168 ms 4600 KB Output is correct
20 Correct 142 ms 4472 KB Output is correct
21 Correct 145 ms 4472 KB Output is correct
22 Correct 43 ms 3320 KB Output is correct
23 Correct 130 ms 4468 KB Output is correct
24 Correct 57 ms 3576 KB Output is correct
25 Correct 75 ms 3708 KB Output is correct
26 Correct 84 ms 3832 KB Output is correct
27 Correct 152 ms 4728 KB Output is correct
28 Correct 171 ms 4856 KB Output is correct
29 Correct 185 ms 4984 KB Output is correct
30 Correct 21 ms 2936 KB Output is correct
31 Correct 38 ms 3192 KB Output is correct
32 Correct 221 ms 4984 KB Output is correct
33 Correct 192 ms 4728 KB Output is correct
34 Correct 38 ms 3192 KB Output is correct
35 Correct 180 ms 4936 KB Output is correct
36 Correct 201 ms 4984 KB Output is correct
37 Correct 187 ms 4728 KB Output is correct
38 Correct 134 ms 4440 KB Output is correct
39 Correct 197 ms 4984 KB Output is correct
40 Correct 17 ms 2936 KB Output is correct
41 Correct 78 ms 3704 KB Output is correct
42 Correct 114 ms 12280 KB Output is correct
43 Correct 54 ms 7324 KB Output is correct
44 Correct 84 ms 10000 KB Output is correct
45 Correct 112 ms 6000 KB Output is correct
46 Correct 30 ms 3576 KB Output is correct
47 Correct 91 ms 10360 KB Output is correct
48 Correct 117 ms 12580 KB Output is correct
49 Correct 136 ms 13908 KB Output is correct
50 Correct 119 ms 6008 KB Output is correct
51 Correct 64 ms 4600 KB Output is correct
52 Correct 90 ms 4344 KB Output is correct
53 Correct 97 ms 4344 KB Output is correct
54 Correct 57 ms 3704 KB Output is correct
55 Correct 101 ms 4344 KB Output is correct
56 Correct 103 ms 3960 KB Output is correct
57 Correct 234 ms 4856 KB Output is correct
58 Correct 54 ms 3704 KB Output is correct
59 Correct 63 ms 3832 KB Output is correct
60 Correct 103 ms 4548 KB Output is correct
61 Correct 49 ms 3448 KB Output is correct
62 Correct 83 ms 4188 KB Output is correct
63 Correct 85 ms 3832 KB Output is correct
64 Correct 54 ms 4092 KB Output is correct
65 Correct 67 ms 4140 KB Output is correct
66 Correct 24 ms 3368 KB Output is correct
67 Correct 21 ms 3332 KB Output is correct
68 Correct 42 ms 3508 KB Output is correct
69 Correct 26 ms 3320 KB Output is correct
70 Correct 52 ms 3668 KB Output is correct
71 Correct 30 ms 3192 KB Output is correct
72 Correct 4 ms 2680 KB Output is correct