답안 #516312

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
516312 2022-01-21T05:15:01 Z jk410 Power Plant (JOI20_power) C++17
0 / 100
1 ms 364 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;
        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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Incorrect 1 ms 364 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Incorrect 1 ms 364 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Incorrect 1 ms 364 KB Output isn't correct
9 Halted 0 ms 0 KB -