# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
417272 | 2021-06-03T14:13:13 Z | jamezzz | Worst Reporter 4 (JOI21_worst_reporter4) | C++17 | 845 ms | 418760 KB |
#include <bits/stdc++.h> using namespace std; #define sf scanf #define pf printf #define fi first #define se second #define pb emplace_back #define INF 1023456789123456789 #define all(x) x.begin(),x.end() #define sz(x) (int)x.size() typedef long long ll; int n,a[200005],h[200005],c[200005]; ll m[5005][5005]; vector<int> AL[200005]; ll dp(int u,int p){ //modifed everything after p, before i if(m[u][p]!=-1)return m[u][p]; ll res=INF; if(h[p]<=h[u]){ //dont need to modify ll tmp=0; for(int v:AL[u])tmp+=dp(v,u); res=min(res,tmp); } ll tmp=c[u]; for(int v:AL[u])tmp+=dp(v,p); res=min(res,tmp); return m[u][p]=res; } int main(){ sf("%d",&n); for(int i=1;i<=n;++i){ sf("%d%d%d",&a[i],&h[i],&c[i]); if(i!=1)AL[a[i]].pb(i); } memset(m,-1,sizeof m); pf("%lld\n",dp(1,0)); } /* 6 1 6 5 1 3 6 1 8 4 3 4 9 2 2 5 2 5 6 20 1 7 381792936 1 89 964898447 1 27 797240712 3 4 299745243 2 18 113181438 2 20 952129455 4 34 124298446 4 89 33466733 7 40 109601410 5 81 902931267 2 4 669879699 8 23 785166502 8 1 601717183 8 26 747624379 1 17 504589209 9 24 909134233 16 56 236448090 8 94 605526613 5 90 481898834 9 34 183442771 */
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 86 ms | 201028 KB | Output is correct |
2 | Correct | 86 ms | 201048 KB | Output is correct |
3 | Correct | 86 ms | 201068 KB | Output is correct |
4 | Correct | 86 ms | 201028 KB | Output is correct |
5 | Correct | 102 ms | 201208 KB | Output is correct |
6 | Correct | 92 ms | 201204 KB | Output is correct |
7 | Correct | 93 ms | 201152 KB | Output is correct |
8 | Correct | 91 ms | 201188 KB | Output is correct |
9 | Correct | 90 ms | 201104 KB | Output is correct |
10 | Correct | 90 ms | 201156 KB | Output is correct |
11 | Correct | 93 ms | 201148 KB | Output is correct |
12 | Correct | 845 ms | 201636 KB | Output is correct |
13 | Correct | 776 ms | 201744 KB | Output is correct |
14 | Correct | 433 ms | 201540 KB | Output is correct |
15 | Correct | 424 ms | 201436 KB | Output is correct |
16 | Correct | 93 ms | 201156 KB | Output is correct |
17 | Correct | 91 ms | 201348 KB | Output is correct |
18 | Correct | 93 ms | 201156 KB | Output is correct |
19 | Correct | 504 ms | 201436 KB | Output is correct |
20 | Correct | 495 ms | 201392 KB | Output is correct |
21 | Correct | 422 ms | 201440 KB | Output is correct |
22 | Correct | 88 ms | 201128 KB | Output is correct |
23 | Correct | 86 ms | 201076 KB | Output is correct |
24 | Correct | 744 ms | 201464 KB | Output is correct |
25 | Correct | 699 ms | 201460 KB | Output is correct |
26 | Correct | 400 ms | 201744 KB | Output is correct |
27 | Correct | 244 ms | 201360 KB | Output is correct |
28 | Correct | 397 ms | 201496 KB | Output is correct |
29 | Correct | 557 ms | 201576 KB | Output is correct |
30 | Correct | 417 ms | 201412 KB | Output is correct |
31 | Correct | 415 ms | 201540 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 86 ms | 201028 KB | Output is correct |
2 | Correct | 86 ms | 201048 KB | Output is correct |
3 | Correct | 86 ms | 201068 KB | Output is correct |
4 | Correct | 86 ms | 201028 KB | Output is correct |
5 | Correct | 102 ms | 201208 KB | Output is correct |
6 | Correct | 92 ms | 201204 KB | Output is correct |
7 | Correct | 93 ms | 201152 KB | Output is correct |
8 | Correct | 91 ms | 201188 KB | Output is correct |
9 | Correct | 90 ms | 201104 KB | Output is correct |
10 | Correct | 90 ms | 201156 KB | Output is correct |
11 | Correct | 93 ms | 201148 KB | Output is correct |
12 | Correct | 845 ms | 201636 KB | Output is correct |
13 | Correct | 776 ms | 201744 KB | Output is correct |
14 | Correct | 433 ms | 201540 KB | Output is correct |
15 | Correct | 424 ms | 201436 KB | Output is correct |
16 | Correct | 93 ms | 201156 KB | Output is correct |
17 | Correct | 91 ms | 201348 KB | Output is correct |
18 | Correct | 93 ms | 201156 KB | Output is correct |
19 | Correct | 504 ms | 201436 KB | Output is correct |
20 | Correct | 495 ms | 201392 KB | Output is correct |
21 | Correct | 422 ms | 201440 KB | Output is correct |
22 | Correct | 88 ms | 201128 KB | Output is correct |
23 | Correct | 86 ms | 201076 KB | Output is correct |
24 | Correct | 744 ms | 201464 KB | Output is correct |
25 | Correct | 699 ms | 201460 KB | Output is correct |
26 | Correct | 400 ms | 201744 KB | Output is correct |
27 | Correct | 244 ms | 201360 KB | Output is correct |
28 | Correct | 397 ms | 201496 KB | Output is correct |
29 | Correct | 557 ms | 201576 KB | Output is correct |
30 | Correct | 417 ms | 201412 KB | Output is correct |
31 | Correct | 415 ms | 201540 KB | Output is correct |
32 | Correct | 90 ms | 201168 KB | Output is correct |
33 | Runtime error | 370 ms | 418760 KB | Execution killed with signal 11 |
34 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 86 ms | 201028 KB | Output is correct |
2 | Correct | 86 ms | 201048 KB | Output is correct |
3 | Correct | 86 ms | 201068 KB | Output is correct |
4 | Correct | 86 ms | 201028 KB | Output is correct |
5 | Correct | 102 ms | 201208 KB | Output is correct |
6 | Correct | 92 ms | 201204 KB | Output is correct |
7 | Correct | 93 ms | 201152 KB | Output is correct |
8 | Correct | 91 ms | 201188 KB | Output is correct |
9 | Correct | 90 ms | 201104 KB | Output is correct |
10 | Correct | 90 ms | 201156 KB | Output is correct |
11 | Correct | 93 ms | 201148 KB | Output is correct |
12 | Correct | 845 ms | 201636 KB | Output is correct |
13 | Correct | 776 ms | 201744 KB | Output is correct |
14 | Correct | 433 ms | 201540 KB | Output is correct |
15 | Correct | 424 ms | 201436 KB | Output is correct |
16 | Correct | 93 ms | 201156 KB | Output is correct |
17 | Correct | 91 ms | 201348 KB | Output is correct |
18 | Correct | 93 ms | 201156 KB | Output is correct |
19 | Correct | 504 ms | 201436 KB | Output is correct |
20 | Correct | 495 ms | 201392 KB | Output is correct |
21 | Correct | 422 ms | 201440 KB | Output is correct |
22 | Correct | 88 ms | 201128 KB | Output is correct |
23 | Correct | 86 ms | 201076 KB | Output is correct |
24 | Correct | 744 ms | 201464 KB | Output is correct |
25 | Correct | 699 ms | 201460 KB | Output is correct |
26 | Correct | 400 ms | 201744 KB | Output is correct |
27 | Correct | 244 ms | 201360 KB | Output is correct |
28 | Correct | 397 ms | 201496 KB | Output is correct |
29 | Correct | 557 ms | 201576 KB | Output is correct |
30 | Correct | 417 ms | 201412 KB | Output is correct |
31 | Correct | 415 ms | 201540 KB | Output is correct |
32 | Correct | 90 ms | 201168 KB | Output is correct |
33 | Runtime error | 370 ms | 418760 KB | Execution killed with signal 11 |
34 | Halted | 0 ms | 0 KB | - |