Submission #868417

# Submission time Handle Problem Language Result Execution time Memory
868417 2023-10-31T13:03:27 Z Cookie Magic Tree (CEOI19_magictree) C++14
34 / 100
1487 ms 1048576 KB
#include<bits/stdc++.h>
#include<fstream>
using namespace std;
ifstream fin("HCN.INP");
ofstream fout("HCN.OUT");
#define sz(a) (int)a.size()
#define ll long long
#define pb push_back
#define forr(i, a, b) for(int i = a; i < b; i++)
#define dorr(i, a, b) for(int i = a; i >= b; i--)
#define ld long double
#define vt vector
#include<fstream>
#define fi first
#define se second
#define pll pair<ll, ll>
#define pii pair<int, int>
const ld PI = 3.14159265359;
//using u128 = __uint128_t;
//const int x[4] = {1, -1, 0, 0};
//const int y[4] = {0, 0, 1, -1};
const ll mod = 1e9 + 9;
const int mxn = 1e5 + 5, mxq = 2e5 + 5, sq = 200, mxv = 2e6 + 5;
const ll inf = 1e17 + 5;
//const int base= (1 << 18);
int n, m, k;
vt<int>adj[mxn + 1];
int day[mxn + 1];
ll cost[mxn + 1], dp[23][mxn + 1], sub[mxn + 1];
void ckmax(ll &a, ll b){
    a = max(a, b);
}
void dfs(int tme, int s){
    dp[tme][s] = dp[tme - 1][s];
    ll tot = 0;
    for(auto i: adj[s]){
        dfs(tme, i);
        tot += dp[tme][i];
    }
    ckmax(dp[tme][s], tot);
    if(day[s] == tme)dp[tme][s] += cost[s];
}
signed main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> m >> k;
    for(int i = 2; i <= n; i++){
        int p; cin >> p;
        adj[p].pb(i);
    }
    for(int i = 0; i < m; i++){
        int v; cin >> v;
        cin >> day[v] >> cost[v];
    }
    ll ans = 0;
    for(int i = 1; i <= k; i++){
        dfs(i, 1);
        for(int j = 1; j <= n; j++){
            ckmax(ans, dp[i][j]);
            sub[j] = 0;
        }
    }
    cout << ans;
    return(0);
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 12124 KB Output is correct
2 Correct 3 ms 18460 KB Output is correct
3 Correct 2 ms 12124 KB Output is correct
4 Correct 2 ms 10076 KB Output is correct
5 Correct 3 ms 18268 KB Output is correct
6 Correct 3 ms 18268 KB Output is correct
7 Correct 3 ms 18268 KB Output is correct
8 Correct 3 ms 18268 KB Output is correct
9 Correct 3 ms 18268 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 96 ms 46948 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 21 ms 41564 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 37 ms 9104 KB Output is correct
2 Correct 31 ms 11100 KB Output is correct
3 Correct 38 ms 15796 KB Output is correct
4 Correct 23 ms 9692 KB Output is correct
5 Correct 48 ms 22252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 12124 KB Output is correct
2 Correct 3 ms 18460 KB Output is correct
3 Correct 2 ms 12124 KB Output is correct
4 Correct 2 ms 10076 KB Output is correct
5 Correct 3 ms 18268 KB Output is correct
6 Correct 3 ms 18268 KB Output is correct
7 Correct 3 ms 18268 KB Output is correct
8 Correct 3 ms 18268 KB Output is correct
9 Correct 3 ms 18268 KB Output is correct
10 Correct 80 ms 24912 KB Output is correct
11 Correct 54 ms 16720 KB Output is correct
12 Correct 69 ms 29724 KB Output is correct
13 Correct 33 ms 23840 KB Output is correct
14 Correct 63 ms 35820 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 1487 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 12124 KB Output is correct
2 Correct 3 ms 18460 KB Output is correct
3 Correct 2 ms 12124 KB Output is correct
4 Correct 2 ms 10076 KB Output is correct
5 Correct 3 ms 18268 KB Output is correct
6 Correct 3 ms 18268 KB Output is correct
7 Correct 3 ms 18268 KB Output is correct
8 Correct 3 ms 18268 KB Output is correct
9 Correct 3 ms 18268 KB Output is correct
10 Runtime error 21 ms 41564 KB Execution killed with signal 11
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 12124 KB Output is correct
2 Correct 3 ms 18460 KB Output is correct
3 Correct 2 ms 12124 KB Output is correct
4 Correct 2 ms 10076 KB Output is correct
5 Correct 3 ms 18268 KB Output is correct
6 Correct 3 ms 18268 KB Output is correct
7 Correct 3 ms 18268 KB Output is correct
8 Correct 3 ms 18268 KB Output is correct
9 Correct 3 ms 18268 KB Output is correct
10 Runtime error 96 ms 46948 KB Execution killed with signal 11
11 Halted 0 ms 0 KB -