Submission #516318

# Submission time Handle Problem Language Result Execution time Memory
516318 2022-01-21T05:21:05 Z jk410 Power Plant (JOI20_power) C++17
47 / 100
94 ms 592 KB
#include <bits/stdc++.h>
using namespace std;
int N,Ans;
int A[2001],DP[2001];
string S;
vector<int> Edge[2001];
int dfs(int v,int par=0){
    DP[v]=-A[v];
    for (int i:Edge[v]){
        if (i==par)
            continue;
        Ans=max(Ans,A[v]+A[i]);
        DP[v]+=dfs(i,v);
    }
    DP[v]=max(DP[v],A[v]);
    return DP[v];
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>N;
    for (int i=1,a,b; i<N; i++){
        cin>>a>>b;
        Edge[a].push_back(b);
        Edge[b].push_back(a);
    }
    cin>>S;
    for (int i=1; i<=N; i++)
        A[i]=(S[i-1]-'0');
    for (int i=1; i<=N; i++)
        Ans=max(Ans,dfs(i));
    cout<<Ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 0 ms 364 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 0 ms 332 KB Output is correct
15 Correct 0 ms 332 KB Output is correct
16 Correct 0 ms 332 KB Output is correct
17 Correct 0 ms 332 KB Output is correct
18 Correct 0 ms 332 KB Output is correct
19 Correct 0 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 0 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 0 ms 364 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 0 ms 332 KB Output is correct
15 Correct 0 ms 332 KB Output is correct
16 Correct 0 ms 332 KB Output is correct
17 Correct 0 ms 332 KB Output is correct
18 Correct 0 ms 332 KB Output is correct
19 Correct 0 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 0 ms 332 KB Output is correct
22 Correct 78 ms 456 KB Output is correct
23 Correct 66 ms 436 KB Output is correct
24 Correct 70 ms 460 KB Output is correct
25 Correct 67 ms 460 KB Output is correct
26 Correct 66 ms 460 KB Output is correct
27 Correct 94 ms 332 KB Output is correct
28 Correct 66 ms 440 KB Output is correct
29 Correct 76 ms 588 KB Output is correct
30 Correct 77 ms 588 KB Output is correct
31 Correct 66 ms 440 KB Output is correct
32 Correct 68 ms 332 KB Output is correct
33 Correct 65 ms 332 KB Output is correct
34 Correct 64 ms 436 KB Output is correct
35 Correct 64 ms 460 KB Output is correct
36 Correct 75 ms 332 KB Output is correct
37 Correct 69 ms 460 KB Output is correct
38 Correct 63 ms 460 KB Output is correct
39 Correct 69 ms 512 KB Output is correct
40 Correct 71 ms 460 KB Output is correct
41 Correct 69 ms 512 KB Output is correct
42 Correct 78 ms 460 KB Output is correct
43 Correct 72 ms 488 KB Output is correct
44 Correct 67 ms 460 KB Output is correct
45 Correct 60 ms 472 KB Output is correct
46 Correct 57 ms 460 KB Output is correct
47 Correct 56 ms 476 KB Output is correct
48 Correct 54 ms 496 KB Output is correct
49 Correct 58 ms 520 KB Output is correct
50 Correct 52 ms 460 KB Output is correct
51 Correct 51 ms 460 KB Output is correct
52 Correct 60 ms 460 KB Output is correct
53 Correct 54 ms 500 KB Output is correct
54 Correct 53 ms 480 KB Output is correct
55 Correct 68 ms 460 KB Output is correct
56 Correct 30 ms 420 KB Output is correct
57 Correct 76 ms 588 KB Output is correct
58 Correct 31 ms 460 KB Output is correct
59 Correct 32 ms 460 KB Output is correct
60 Correct 79 ms 592 KB Output is correct
61 Correct 33 ms 476 KB Output is correct
62 Correct 78 ms 504 KB Output is correct
63 Correct 51 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 0 ms 364 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 0 ms 332 KB Output is correct
15 Correct 0 ms 332 KB Output is correct
16 Correct 0 ms 332 KB Output is correct
17 Correct 0 ms 332 KB Output is correct
18 Correct 0 ms 332 KB Output is correct
19 Correct 0 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 0 ms 332 KB Output is correct
22 Correct 78 ms 456 KB Output is correct
23 Correct 66 ms 436 KB Output is correct
24 Correct 70 ms 460 KB Output is correct
25 Correct 67 ms 460 KB Output is correct
26 Correct 66 ms 460 KB Output is correct
27 Correct 94 ms 332 KB Output is correct
28 Correct 66 ms 440 KB Output is correct
29 Correct 76 ms 588 KB Output is correct
30 Correct 77 ms 588 KB Output is correct
31 Correct 66 ms 440 KB Output is correct
32 Correct 68 ms 332 KB Output is correct
33 Correct 65 ms 332 KB Output is correct
34 Correct 64 ms 436 KB Output is correct
35 Correct 64 ms 460 KB Output is correct
36 Correct 75 ms 332 KB Output is correct
37 Correct 69 ms 460 KB Output is correct
38 Correct 63 ms 460 KB Output is correct
39 Correct 69 ms 512 KB Output is correct
40 Correct 71 ms 460 KB Output is correct
41 Correct 69 ms 512 KB Output is correct
42 Correct 78 ms 460 KB Output is correct
43 Correct 72 ms 488 KB Output is correct
44 Correct 67 ms 460 KB Output is correct
45 Correct 60 ms 472 KB Output is correct
46 Correct 57 ms 460 KB Output is correct
47 Correct 56 ms 476 KB Output is correct
48 Correct 54 ms 496 KB Output is correct
49 Correct 58 ms 520 KB Output is correct
50 Correct 52 ms 460 KB Output is correct
51 Correct 51 ms 460 KB Output is correct
52 Correct 60 ms 460 KB Output is correct
53 Correct 54 ms 500 KB Output is correct
54 Correct 53 ms 480 KB Output is correct
55 Correct 68 ms 460 KB Output is correct
56 Correct 30 ms 420 KB Output is correct
57 Correct 76 ms 588 KB Output is correct
58 Correct 31 ms 460 KB Output is correct
59 Correct 32 ms 460 KB Output is correct
60 Correct 79 ms 592 KB Output is correct
61 Correct 33 ms 476 KB Output is correct
62 Correct 78 ms 504 KB Output is correct
63 Correct 51 ms 332 KB Output is correct
64 Runtime error 1 ms 588 KB Execution killed with signal 11
65 Halted 0 ms 0 KB -