답안 #18501

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
18501 2016-02-06T12:07:12 Z eaststar Company Planning (TOKI14_company) C++14
100 / 100
195 ms 3792 KB
#include <stdio.h>
#include <queue>
using namespace std;
struct al{
    int e,nx;
}a[100010];
int st[100010],D[100010],t,ans;
void make_al(int s,int e){a[++t].nx=st[s],a[t].e=e,st[s]=t;}
void f(int p,int m){
    int i,cnt=0;
    priority_queue<int> q;
    for(i=st[p];i;i=a[i].nx)q.push(D[a[i].e]);
    D[p]=1;
    for(;!q.empty()&&cnt<m;++cnt){
        D[p]+=q.top();
        q.pop();
    }
}
int main(){
    int i,n,k,p,l,r,m;
    scanf("%d%d",&n,&k);
    for(i=2;i<=n;++i){
        scanf("%d",&p);
        make_al(p,i);
    }
    l=0,r=n;
    while(l<=r){
        m=(l+r)/2;
        for(i=n;i;--i)
            f(i,m);
        if(D[1]<k)l=m+1;
        else r=m-1,ans=m;
    }
    printf("%d",ans);
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2772 KB Output is correct
2 Correct 0 ms 2772 KB Output is correct
3 Correct 0 ms 2772 KB Output is correct
4 Correct 0 ms 2772 KB Output is correct
5 Correct 0 ms 2772 KB Output is correct
6 Correct 0 ms 2772 KB Output is correct
7 Correct 0 ms 2772 KB Output is correct
8 Correct 0 ms 2772 KB Output is correct
9 Correct 0 ms 2772 KB Output is correct
10 Correct 0 ms 2772 KB Output is correct
11 Correct 0 ms 2772 KB Output is correct
12 Correct 0 ms 2772 KB Output is correct
13 Correct 0 ms 2772 KB Output is correct
14 Correct 0 ms 2772 KB Output is correct
15 Correct 0 ms 2772 KB Output is correct
16 Correct 0 ms 2772 KB Output is correct
17 Correct 0 ms 2772 KB Output is correct
18 Correct 0 ms 2772 KB Output is correct
19 Correct 0 ms 2772 KB Output is correct
20 Correct 0 ms 2772 KB Output is correct
21 Correct 0 ms 2772 KB Output is correct
22 Correct 0 ms 2772 KB Output is correct
23 Correct 0 ms 2772 KB Output is correct
24 Correct 0 ms 2772 KB Output is correct
25 Correct 0 ms 2772 KB Output is correct
26 Correct 0 ms 2772 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2772 KB Output is correct
2 Correct 0 ms 2772 KB Output is correct
3 Correct 0 ms 2772 KB Output is correct
4 Correct 0 ms 2772 KB Output is correct
5 Correct 0 ms 2772 KB Output is correct
6 Correct 0 ms 2772 KB Output is correct
7 Correct 0 ms 2772 KB Output is correct
8 Correct 0 ms 2772 KB Output is correct
9 Correct 0 ms 2772 KB Output is correct
10 Correct 0 ms 2772 KB Output is correct
11 Correct 1 ms 2772 KB Output is correct
12 Correct 0 ms 2772 KB Output is correct
13 Correct 0 ms 2772 KB Output is correct
14 Correct 1 ms 2772 KB Output is correct
15 Correct 0 ms 2772 KB Output is correct
16 Correct 0 ms 2772 KB Output is correct
17 Correct 0 ms 2772 KB Output is correct
18 Correct 0 ms 2772 KB Output is correct
19 Correct 0 ms 2772 KB Output is correct
20 Correct 0 ms 2772 KB Output is correct
21 Correct 0 ms 2772 KB Output is correct
22 Correct 0 ms 2772 KB Output is correct
23 Correct 0 ms 2772 KB Output is correct
24 Correct 0 ms 2772 KB Output is correct
25 Correct 0 ms 2772 KB Output is correct
26 Correct 0 ms 2772 KB Output is correct
27 Correct 0 ms 2772 KB Output is correct
28 Correct 0 ms 2772 KB Output is correct
29 Correct 0 ms 2772 KB Output is correct
30 Correct 0 ms 2772 KB Output is correct
31 Correct 0 ms 2772 KB Output is correct
32 Correct 0 ms 2772 KB Output is correct
33 Correct 0 ms 2772 KB Output is correct
34 Correct 1 ms 2772 KB Output is correct
35 Correct 0 ms 2772 KB Output is correct
36 Correct 0 ms 2772 KB Output is correct
37 Correct 0 ms 2772 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2772 KB Output is correct
2 Correct 144 ms 2772 KB Output is correct
3 Correct 125 ms 2772 KB Output is correct
4 Correct 119 ms 2772 KB Output is correct
5 Correct 128 ms 2772 KB Output is correct
6 Correct 125 ms 2772 KB Output is correct
7 Correct 119 ms 2772 KB Output is correct
8 Correct 116 ms 2772 KB Output is correct
9 Correct 114 ms 2772 KB Output is correct
10 Correct 105 ms 2772 KB Output is correct
11 Correct 98 ms 2772 KB Output is correct
12 Correct 132 ms 2772 KB Output is correct
13 Correct 136 ms 2772 KB Output is correct
14 Correct 82 ms 2772 KB Output is correct
15 Correct 118 ms 2772 KB Output is correct
16 Correct 78 ms 2772 KB Output is correct
17 Correct 99 ms 2772 KB Output is correct
18 Correct 59 ms 2772 KB Output is correct
19 Correct 43 ms 2772 KB Output is correct
20 Correct 86 ms 2772 KB Output is correct
21 Correct 62 ms 2772 KB Output is correct
22 Correct 27 ms 2772 KB Output is correct
23 Correct 92 ms 2772 KB Output is correct
24 Correct 108 ms 2772 KB Output is correct
25 Correct 0 ms 2772 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2772 KB Output is correct
2 Correct 170 ms 3024 KB Output is correct
3 Correct 189 ms 3792 KB Output is correct
4 Correct 125 ms 2772 KB Output is correct
5 Correct 108 ms 2772 KB Output is correct
6 Correct 120 ms 2772 KB Output is correct
7 Correct 107 ms 2772 KB Output is correct
8 Correct 137 ms 2772 KB Output is correct
9 Correct 145 ms 2772 KB Output is correct
10 Correct 113 ms 2772 KB Output is correct
11 Correct 46 ms 2772 KB Output is correct
12 Correct 129 ms 2772 KB Output is correct
13 Correct 93 ms 2772 KB Output is correct
14 Correct 129 ms 2772 KB Output is correct
15 Correct 137 ms 2772 KB Output is correct
16 Correct 69 ms 2772 KB Output is correct
17 Correct 62 ms 2772 KB Output is correct
18 Correct 99 ms 2772 KB Output is correct
19 Correct 102 ms 2772 KB Output is correct
20 Correct 54 ms 2772 KB Output is correct
21 Correct 24 ms 2772 KB Output is correct
22 Correct 44 ms 2772 KB Output is correct
23 Correct 55 ms 2772 KB Output is correct
24 Correct 63 ms 2772 KB Output is correct
25 Correct 52 ms 2772 KB Output is correct
26 Correct 99 ms 2772 KB Output is correct
27 Correct 114 ms 2772 KB Output is correct
28 Correct 74 ms 2772 KB Output is correct
29 Correct 93 ms 2772 KB Output is correct
30 Correct 89 ms 2772 KB Output is correct
31 Correct 90 ms 2772 KB Output is correct
32 Correct 25 ms 2772 KB Output is correct
33 Correct 64 ms 3280 KB Output is correct
34 Correct 65 ms 2772 KB Output is correct
35 Correct 11 ms 2772 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2772 KB Output is correct
2 Correct 72 ms 3024 KB Output is correct
3 Correct 162 ms 3792 KB Output is correct
4 Correct 123 ms 2772 KB Output is correct
5 Correct 120 ms 2772 KB Output is correct
6 Correct 125 ms 2772 KB Output is correct
7 Correct 111 ms 2772 KB Output is correct
8 Correct 134 ms 2772 KB Output is correct
9 Correct 173 ms 3280 KB Output is correct
10 Correct 195 ms 3792 KB Output is correct
11 Correct 125 ms 2772 KB Output is correct
12 Correct 121 ms 2772 KB Output is correct
13 Correct 115 ms 2772 KB Output is correct
14 Correct 114 ms 2772 KB Output is correct
15 Correct 145 ms 2772 KB Output is correct
16 Correct 143 ms 2772 KB Output is correct
17 Correct 143 ms 2772 KB Output is correct
18 Correct 134 ms 2772 KB Output is correct
19 Correct 102 ms 2772 KB Output is correct
20 Correct 97 ms 2772 KB Output is correct
21 Correct 105 ms 2772 KB Output is correct
22 Correct 30 ms 2772 KB Output is correct
23 Correct 86 ms 2772 KB Output is correct
24 Correct 35 ms 2772 KB Output is correct
25 Correct 56 ms 2772 KB Output is correct
26 Correct 64 ms 2772 KB Output is correct
27 Correct 121 ms 2772 KB Output is correct
28 Correct 125 ms 2772 KB Output is correct
29 Correct 138 ms 2772 KB Output is correct
30 Correct 13 ms 2772 KB Output is correct
31 Correct 24 ms 2772 KB Output is correct
32 Correct 139 ms 2772 KB Output is correct
33 Correct 130 ms 2772 KB Output is correct
34 Correct 30 ms 2772 KB Output is correct
35 Correct 135 ms 2772 KB Output is correct
36 Correct 144 ms 2772 KB Output is correct
37 Correct 107 ms 2772 KB Output is correct
38 Correct 97 ms 2772 KB Output is correct
39 Correct 132 ms 2772 KB Output is correct
40 Correct 12 ms 2772 KB Output is correct
41 Correct 58 ms 2772 KB Output is correct
42 Correct 91 ms 2772 KB Output is correct
43 Correct 42 ms 2772 KB Output is correct
44 Correct 70 ms 2772 KB Output is correct
45 Correct 96 ms 2772 KB Output is correct
46 Correct 20 ms 2772 KB Output is correct
47 Correct 65 ms 2772 KB Output is correct
48 Correct 88 ms 2772 KB Output is correct
49 Correct 101 ms 2772 KB Output is correct
50 Correct 103 ms 2772 KB Output is correct
51 Correct 53 ms 2772 KB Output is correct
52 Correct 87 ms 2772 KB Output is correct
53 Correct 84 ms 2772 KB Output is correct
54 Correct 54 ms 2772 KB Output is correct
55 Correct 88 ms 2772 KB Output is correct
56 Correct 70 ms 2772 KB Output is correct
57 Correct 109 ms 2772 KB Output is correct
58 Correct 51 ms 2772 KB Output is correct
59 Correct 64 ms 2772 KB Output is correct
60 Correct 96 ms 2772 KB Output is correct
61 Correct 43 ms 2772 KB Output is correct
62 Correct 70 ms 2772 KB Output is correct
63 Correct 58 ms 2772 KB Output is correct
64 Correct 113 ms 3792 KB Output is correct
65 Correct 168 ms 3792 KB Output is correct
66 Correct 48 ms 3024 KB Output is correct
67 Correct 41 ms 3024 KB Output is correct
68 Correct 93 ms 3024 KB Output is correct
69 Correct 52 ms 2772 KB Output is correct
70 Correct 132 ms 3280 KB Output is correct
71 Correct 68 ms 2772 KB Output is correct
72 Correct 0 ms 2772 KB Output is correct