답안 #972822

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
972822 2024-05-01T08:31:19 Z phoenix Magic Tree (CEOI19_magictree) C++17
34 / 100
555 ms 1048576 KB
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int n, m, k;

const int N = 100100;

int w[N];
int d[N];
int p[N];

int main() {
    ios::sync_with_stdio(0),
    cin.tie(0);
    cin >> n >> m >> k;
    for (int i = 2; i <= n; i++) 
        cin >> p[i];
    for (int i = 0; i < m; i++) {
        int u;
        cin >> u;
        cin >> d[u] >> w[u];
    }
    vector<vector<ll>> dp(n + 1, vector<ll>(k + 1, 0));
    for (int i = n; i >= 1; i--) {
        ll val = dp[i][d[i]] + w[i];
        for (int j = d[i]; j <= k; j++) 
            dp[i][j] = max(dp[i][j], val);
        for (int j = 1; j <= k; j++) 
            dp[p[i]][j] += dp[i][j];
    }
    cout << dp[1][k] << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 555 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 8280 KB Output is correct
2 Correct 6 ms 8288 KB Output is correct
3 Correct 5 ms 8392 KB Output is correct
4 Runtime error 433 ms 1048576 KB Execution killed with signal 9
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 9052 KB Output is correct
2 Correct 28 ms 9040 KB Output is correct
3 Correct 28 ms 9012 KB Output is correct
4 Correct 26 ms 8656 KB Output is correct
5 Correct 28 ms 9056 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 44 ms 22608 KB Output is correct
11 Correct 29 ms 14672 KB Output is correct
12 Correct 36 ms 22616 KB Output is correct
13 Correct 31 ms 22120 KB Output is correct
14 Correct 32 ms 22608 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 359 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 6 ms 8280 KB Output is correct
11 Correct 6 ms 8288 KB Output is correct
12 Correct 5 ms 8392 KB Output is correct
13 Runtime error 433 ms 1048576 KB Execution killed with signal 9
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Runtime error 555 ms 1048576 KB Execution killed with signal 9
11 Halted 0 ms 0 KB -