# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
278016 | 2020-08-21T08:49:12 Z | AKaan37 | Magic Tree (CEOI19_magictree) | C++17 | 132 ms | 31736 KB |
//Bismillahirrahmanirrahim //█▀█─█──█──█▀█─█─█ //█▄█─█──█──█▄█─█▄█ //█─█─█▄─█▄─█─█─█─█ #include <bits/stdc++.h> using namespace std; typedef long long lo; typedef pair< lo,lo > PII; #define fi first #define se second #define int long long #define mp make_pair #define endl "\n" #define pb push_back #define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) #define FOR for(int i=1;i<=n;i++) #define mid ((start+end)/2) #define ort ((bas+son)/2) const lo inf = 1000000000000000000; const lo KOK = 100000; const lo LOG = 30; const lo li = 100005; const lo mod = 1000000007; int n,m,b[li],a[li],k,flag,t,dp[li][25]; int cev; string s; PII p[li]; vector<int> v[li]; inline void dfs(int node,int ata){ for(int i=0;i<(int)v[node].size();i++){ int go=v[node][i]; if(go==ata)continue; dfs(go,node); } if(p[node].fi!=0){ for(int i=p[node].fi;i<=p[node].fi;i++){ dp[node][i]=max(dp[node][i],(dp[node][p[node].fi]+p[node].se)); } } for(int i=1;i<=k;i++)dp[node][i]=max(dp[node][i],dp[node][i-1]); //~ cout for(int i=1;i<=k;i++){ dp[ata][i]+=(dp[node][i]); } } main(void){ scanf("%lld %lld %lld",&n,&m,&k); for(int i=2;i<=n;i++){ int x; scanf("%lld",&x); v[i].pb(x); v[x].pb(i); } for(int i=1;i<=m;i++){ int x,y,z; scanf("%lld %lld %lld",&x,&y,&z); cev+=z; p[x].fi=y; p[x].se=z; } if(k<=20){ cev=0; dfs(1,0); for(int i=1;i<=k;i++)cev=max(cev,dp[i][k]); } printf("%lld\n",cev); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 2688 KB | Output is correct |
2 | Correct | 2 ms | 2688 KB | Output is correct |
3 | Correct | 2 ms | 2688 KB | Output is correct |
4 | Correct | 2 ms | 2688 KB | Output is correct |
5 | Correct | 2 ms | 2688 KB | Output is correct |
6 | Correct | 2 ms | 2688 KB | Output is correct |
7 | Correct | 2 ms | 2688 KB | Output is correct |
8 | Correct | 2 ms | 2688 KB | Output is correct |
9 | Correct | 2 ms | 2688 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 51 ms | 8056 KB | Output is correct |
2 | Correct | 41 ms | 7456 KB | Output is correct |
3 | Correct | 76 ms | 10872 KB | Output is correct |
4 | Correct | 84 ms | 10216 KB | Output is correct |
5 | Correct | 72 ms | 10744 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 2688 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 132 ms | 27580 KB | Output is correct |
2 | Correct | 113 ms | 27544 KB | Output is correct |
3 | Correct | 88 ms | 29048 KB | Output is correct |
4 | Correct | 71 ms | 27756 KB | Output is correct |
5 | Correct | 76 ms | 31736 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 2688 KB | Output is correct |
2 | Correct | 2 ms | 2688 KB | Output is correct |
3 | Correct | 2 ms | 2688 KB | Output is correct |
4 | Correct | 2 ms | 2688 KB | Output is correct |
5 | Correct | 2 ms | 2688 KB | Output is correct |
6 | Correct | 2 ms | 2688 KB | Output is correct |
7 | Correct | 2 ms | 2688 KB | Output is correct |
8 | Correct | 2 ms | 2688 KB | Output is correct |
9 | Correct | 2 ms | 2688 KB | Output is correct |
10 | Correct | 110 ms | 27640 KB | Output is correct |
11 | Correct | 110 ms | 27596 KB | Output is correct |
12 | Correct | 90 ms | 29188 KB | Output is correct |
13 | Correct | 71 ms | 27756 KB | Output is correct |
14 | Correct | 74 ms | 31608 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 8 ms | 3712 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 2688 KB | Output is correct |
2 | Correct | 2 ms | 2688 KB | Output is correct |
3 | Correct | 2 ms | 2688 KB | Output is correct |
4 | Correct | 2 ms | 2688 KB | Output is correct |
5 | Correct | 2 ms | 2688 KB | Output is correct |
6 | Correct | 2 ms | 2688 KB | Output is correct |
7 | Correct | 2 ms | 2688 KB | Output is correct |
8 | Correct | 2 ms | 2688 KB | Output is correct |
9 | Correct | 2 ms | 2688 KB | Output is correct |
10 | Incorrect | 3 ms | 2688 KB | Output isn't correct |
11 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 2688 KB | Output is correct |
2 | Correct | 2 ms | 2688 KB | Output is correct |
3 | Correct | 2 ms | 2688 KB | Output is correct |
4 | Correct | 2 ms | 2688 KB | Output is correct |
5 | Correct | 2 ms | 2688 KB | Output is correct |
6 | Correct | 2 ms | 2688 KB | Output is correct |
7 | Correct | 2 ms | 2688 KB | Output is correct |
8 | Correct | 2 ms | 2688 KB | Output is correct |
9 | Correct | 2 ms | 2688 KB | Output is correct |
10 | Correct | 51 ms | 8056 KB | Output is correct |
11 | Correct | 41 ms | 7456 KB | Output is correct |
12 | Correct | 76 ms | 10872 KB | Output is correct |
13 | Correct | 84 ms | 10216 KB | Output is correct |
14 | Correct | 72 ms | 10744 KB | Output is correct |
15 | Incorrect | 3 ms | 2688 KB | Output isn't correct |
16 | Halted | 0 ms | 0 KB | - |