답안 #723635

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
723635 2023-04-14T06:44:55 Z dxz05 Magic Tree (CEOI19_magictree) C++17
34 / 100
100 ms 56012 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
#define all(x) (x).begin(), (x).end()
#define MP make_pair
const int N = 100500;

vector<int> g[N];

ll dp[N][30];
pair<int, int> fruit[N];

void dfs(int v){
    dp[v][fruit[v].first] = fruit[v].second;

    for (int u : g[v]){
        dfs(u);
    }

    for (int t = 1; t <= 20; t++){
        for (int u : g[v]){
            dp[v][t] += *max_element(dp[u], dp[u] + t + 1);
        }
    }
}

void solve(){
    int n, m, k;
    cin >> n >> m >> k;

    for (int i = 2; i <= n; i++){
        int p;
        cin >> p;
        g[p].push_back(i);
    }

    for (int i = 0; i < m; i++){
        int v, d, w;
        cin >> v >> d >> w;
        fruit[v] = MP(d, w);
    }

    dfs(1);

    cout << *max_element(dp[1], dp[1] + 30) << endl;

}

int main() {
    ios_base::sync_with_stdio(false);

#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    solve();

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 2 ms 2644 KB Output is correct
4 Correct 1 ms 2644 KB Output is correct
5 Correct 2 ms 2644 KB Output is correct
6 Correct 1 ms 2644 KB Output is correct
7 Correct 2 ms 2644 KB Output is correct
8 Correct 2 ms 2644 KB Output is correct
9 Correct 1 ms 2644 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 67 ms 56012 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 2900 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 99 ms 28624 KB Output is correct
2 Correct 100 ms 28636 KB Output is correct
3 Correct 89 ms 31260 KB Output is correct
4 Correct 77 ms 27472 KB Output is correct
5 Correct 78 ms 34672 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 2 ms 2644 KB Output is correct
4 Correct 1 ms 2644 KB Output is correct
5 Correct 2 ms 2644 KB Output is correct
6 Correct 1 ms 2644 KB Output is correct
7 Correct 2 ms 2644 KB Output is correct
8 Correct 2 ms 2644 KB Output is correct
9 Correct 1 ms 2644 KB Output is correct
10 Correct 88 ms 28548 KB Output is correct
11 Correct 93 ms 28560 KB Output is correct
12 Correct 80 ms 31316 KB Output is correct
13 Correct 78 ms 27408 KB Output is correct
14 Correct 88 ms 34692 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 13 ms 7892 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 2 ms 2644 KB Output is correct
4 Correct 1 ms 2644 KB Output is correct
5 Correct 2 ms 2644 KB Output is correct
6 Correct 1 ms 2644 KB Output is correct
7 Correct 2 ms 2644 KB Output is correct
8 Correct 2 ms 2644 KB Output is correct
9 Correct 1 ms 2644 KB Output is correct
10 Incorrect 2 ms 2900 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 2 ms 2644 KB Output is correct
4 Correct 1 ms 2644 KB Output is correct
5 Correct 2 ms 2644 KB Output is correct
6 Correct 1 ms 2644 KB Output is correct
7 Correct 2 ms 2644 KB Output is correct
8 Correct 2 ms 2644 KB Output is correct
9 Correct 1 ms 2644 KB Output is correct
10 Runtime error 67 ms 56012 KB Execution killed with signal 11
11 Halted 0 ms 0 KB -