Submission #925180

# Submission time Handle Problem Language Result Execution time Memory
925180 2024-02-10T23:58:50 Z 12345678 Magic Tree (CEOI19_magictree) C++17
34 / 100
2000 ms 33884 KB
#include <bits/stdc++.h>

using namespace std;

#define ll long long

const int nx=1e5+5, kx=21;
ll n, m, k, t[nx], w[nx], p, dp[nx][kx], x, ans, vl;
vector<int> d[nx];

void dfs(int u)
{
    for (auto v:d[u]) 
    {
        dfs(v);
        for (int i=1; i<=k; i++) dp[u][i]+=dp[v][i];
    }
    dp[u][t[u]]+=w[u];
    for (int i=t[u]+1; i<=k; i++) dp[u][i]=max(dp[u][i], dp[u][i-1]);
}

int main()
{
    cin.tie(NULL)->sync_with_stdio(false);
    cin>>n>>m>>k;
    for (int i=2; i<=n; i++) cin>>p, d[p].push_back(i);
    for (int i=1; i<=m; i++) cin>>x>>t[x]>>w[x];
    dfs(1);
    for (int i=1; i<=k; i++) ans=max(ans, dp[1][i]);
    cout<<ans<<'\n';
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4696 KB Output is correct
2 Correct 1 ms 4700 KB Output is correct
3 Correct 1 ms 4700 KB Output is correct
4 Correct 1 ms 4696 KB Output is correct
5 Correct 1 ms 4700 KB Output is correct
6 Correct 1 ms 4700 KB Output is correct
7 Correct 1 ms 4700 KB Output is correct
8 Correct 1 ms 4700 KB Output is correct
9 Correct 1 ms 4700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2055 ms 23124 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 4700 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 37 ms 24408 KB Output is correct
2 Correct 36 ms 24408 KB Output is correct
3 Correct 36 ms 28380 KB Output is correct
4 Correct 23 ms 23000 KB Output is correct
5 Correct 32 ms 33884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4696 KB Output is correct
2 Correct 1 ms 4700 KB Output is correct
3 Correct 1 ms 4700 KB Output is correct
4 Correct 1 ms 4696 KB Output is correct
5 Correct 1 ms 4700 KB Output is correct
6 Correct 1 ms 4700 KB Output is correct
7 Correct 1 ms 4700 KB Output is correct
8 Correct 1 ms 4700 KB Output is correct
9 Correct 1 ms 4700 KB Output is correct
10 Correct 48 ms 23644 KB Output is correct
11 Correct 45 ms 23644 KB Output is correct
12 Correct 40 ms 27740 KB Output is correct
13 Correct 26 ms 22232 KB Output is correct
14 Correct 33 ms 33104 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2100 ms 7512 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4696 KB Output is correct
2 Correct 1 ms 4700 KB Output is correct
3 Correct 1 ms 4700 KB Output is correct
4 Correct 1 ms 4696 KB Output is correct
5 Correct 1 ms 4700 KB Output is correct
6 Correct 1 ms 4700 KB Output is correct
7 Correct 1 ms 4700 KB Output is correct
8 Correct 1 ms 4700 KB Output is correct
9 Correct 1 ms 4700 KB Output is correct
10 Incorrect 4 ms 4700 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4696 KB Output is correct
2 Correct 1 ms 4700 KB Output is correct
3 Correct 1 ms 4700 KB Output is correct
4 Correct 1 ms 4696 KB Output is correct
5 Correct 1 ms 4700 KB Output is correct
6 Correct 1 ms 4700 KB Output is correct
7 Correct 1 ms 4700 KB Output is correct
8 Correct 1 ms 4700 KB Output is correct
9 Correct 1 ms 4700 KB Output is correct
10 Execution timed out 2055 ms 23124 KB Time limit exceeded
11 Halted 0 ms 0 KB -