UOJ Logo

NOI.AC

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#198706#2452. BUperFicial100789ms169284kbC++1.1kb2023-11-30 08:02:462023-11-30 12:10:42

answer

#include<bits/stdc++.h>
#define N 81
#define int long long
#define inf 1000000000000000000ll
using namespace std;
int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int f[N][N][N*N/2],n,x[N],y[N],z[N],m,t,num;
signed main()
{
	num=read();t=read();
	while(t--)
	{
		n=read();m=(n+1)*n/2;
		for(int i=n;i>=1;i--)
		{
			x[i]=read();
			y[i]=read();
			z[i]=read();
		}
		for(int i=0;i<=n;i++)
		{
			for(int j=0;j<=n;j++)
			{
				for(int k=0;k<=m;k++)
				f[i][j][k]=-inf;
			}
		}
		f[0][0][0]=0;
		for(int i=1;i<=n;i++)
		{
			for(int j=0;j<i;j++)
			{
				for(int k=0,con=i*(i-1)/2;k<=con;k++)
				{
					f[i][j+1][k+i]=max(f[i][j+1][k+i],f[i-1][j][k]+x[i]);
					f[i][j][k]=max(f[i][j][k],f[i-1][j][k]+j*y[i]);
					f[i][j][k]=max(f[i][j][k],f[i-1][j][k]+(i*j-k)*z[i]); 
				}
			}
		}
		int ans=0;
		for(int i=0;i<=n;i++)
		{
			for(int k=0;k<=m;k++)
			ans=max(ans,f[n][i][k]);
		}
		cout<<ans<<"\n"; 
	}
	return 0;
}

Details

小提示:点击横条可展开更详细的信息

Test #1:

score: 5
Accepted
time: 0ms
memory: 1168kb

input:

1
10
1
0 3 0
1
521 11 595
1
417455 17317 50844
1
70192 6508565 1106210
1
17 25 15
1
18693432 6637271...

output:

0
521
417455
70192
17
18693432
9976
5651
1
9184

result:

ok 10 lines

Test #2:

score: 5
Accepted
time: 0ms
memory: 1188kb

input:

2
10
2
883 300 1298
56 8734 9326
2
424871171 194336280 811712274
55219032 78665177 9082197
2
1011072...

output:

1354
866931306
43903260
752
7
13236079
55
1601604
738346267
1268

result:

ok 10 lines

Test #3:

score: 5
Accepted
time: 0ms
memory: 1680kb

input:

3
10
10
158046 841932 1256173
764231 195526 6775904
6802298 6722619 69663
205872 225656 103128
10111...

output:

370423877
2820
227132
168
17586678490
40474811441
2139068539
41839
9637258
56193459

result:

ok 10 lines

Test #4:

score: 5
Accepted
time: 0ms
memory: 1684kb

input:

4
10
10
0 0 0
0 0 0
0 2 4
0 7 2
9 0 2
0 0 0
0 6 9
1 0 0
0 0 0
3 9 6
10
1549761 34003809 569024446
83...

output:

202
39132937521
8947031
69
28990985
562
15321357
90846
56301000056
31543001

result:

ok 10 lines

Test #5:

score: 5
Accepted
time: 0ms
memory: 1680kb

input:

5
10
10
3140 18315 27746
2941 45397 85348
238 72892 878
4924 8833 69479
4117 7978 13129
19924 89781 ...

output:

5825340
117496
307663
439403024
21301
3697509
222
2317277004
121
5010616

result:

ok 10 lines

Test #6:

score: 5
Accepted
time: 20ms
memory: 37568kb

input:

6
25
20
7462001 0 0
22348000 0 0
751769 0 0
198036 0 0
4863163 0 0
1840546 0 0
75038768 0 0
92270896...

output:

597398806
15
41
5120854220
366920
33023779
12
10
5064857697
4849521923
3651
368
20867
4947543
299531...

result:

ok 25 lines

Test #7:

score: 5
Accepted
time: 20ms
memory: 37564kb

input:

7
25
20
6 0 0
63 12 0
54 0 0
19 0 0
85 6 0
0 3 0
49 0 0
7 0 0
68 86 0
0 0 0
8 0 0
69 6 0
0 6 0
7 61 ...

output:

2117
7350
4572
54231297
72492825
6413
533326232
2983
63249654
345
708154424
4883
58141837
51744
4655...

result:

ok 25 lines

Test #8:

score: 5
Accepted
time: 15ms
memory: 37564kb

input:

8
25
20
46513 0 0
6253 63 0
77863 0 0
91225 0 0
3617 81 0
7346 3 0
7291 0 0
94938 4 0
4355 93 0
4621...

output:

581570
40390
37656819
5401267
307027
3463573
265
36126624
53576798
477310
4994325
253590568
60288325...

result:

ok 25 lines

Test #9:

score: 5
Accepted
time: 20ms
memory: 37564kb

input:

9
25
20
92945909 6691160 0
96720852 280897269 0
352257151 36544435 0
298101282 654916992 0
65917979 ...

output:

30786974329
247916
261
434679
48072973
4783
1604459552
4760
2023727
2970967
2344396
24367579935
2679...

result:

ok 25 lines

Test #10:

score: 5
Accepted
time: 16ms
memory: 37564kb

input:

10
25
20
723 121 0
60 874 0
9 729 0
464 88 0
27 217 0
308 86 0
119 22 0
0 35 0
82 377 0
8 43 0
80 6 ...

output:

36671
36440973662
2044237456
239
41262391857
228
197
303667227
4843
2533448676
248
22508334
236721
2...

result:

ok 25 lines

Test #11:

score: 5
Accepted
time: 19ms
memory: 37568kb

input:

11
25
20
705653 81928 0
140959 18722 0
95113 78108 0
35133 36503 0
88419 343409 0
247339 331677 0
68...

output:

24931234
532367626
215
211223651
3322
181172
39089333916
480499498
39547
3300414290
391252
254966
32...

result:

ok 25 lines

Test #12:

score: 5
Accepted
time: 91ms
memory: 169280kb

input:

12
25
20
78397049 2637194 0
44802760 18444905 0
33107269 792996829 0
880561270 171991508 0
957744407...

output:

35394181636
1486254778
498298
3636084
32785
20549459208
4088179197
3878242847
3205
29672772
29165011...

result:

ok 25 lines

Test #13:

score: 5
Accepted
time: 95ms
memory: 169284kb

input:

13
25
20
29 8312 0
444 307 0
45 698 0
7640 5152 0
2292 858 0
698 5197 0
334 7807 0
7623 1067 0
63 33...

output:

456029
2887
35649394384
309
21975
430338378
3242121226
34565338497
52272016282
396019484
17734046566...

result:

ok 25 lines

Test #14:

score: 5
Accepted
time: 104ms
memory: 169284kb

input:

14
25
20
697809 903083 0
18436 8465719 0
455133 45918 0
80171 4380073 0
2817219 88985 0
2221980 2606...

output:

419114700
329676359
397655795
219
32808298
3381109471
269
167
358543
20614639
38301
3464991
52454742...

result:

ok 25 lines

Test #15:

score: 5
Accepted
time: 12ms
memory: 37564kb

input:

15
25
20
3 0 4
0 6 2
0 0 5
0 0 0
9 0 0
0 0 0
0 8 0
0 0 0
0 4 6
0 0 2
0 5 9
0 2 6
0 0 3
0 0 0
0 0 6
0...

output:

2600
339340
185410311561
154575658694
126699663333
24601818340
1880736
3715
2832912904
3089
2229
168...

result:

ok 25 lines

Test #16:

score: 5
Accepted
time: 22ms
memory: 37568kb

input:

16
25
20
94236 5558 66838
78677 13431 56506
54168 876 95216
396 2073 9264
8979 97417 838
8111 3592 7...

output:

44832591
24893
1951
2165
15517630429
35653782421
21911224239
239251
5792217737
334640378001
13323124...

result:

ok 25 lines

Test #17:

score: 5
Accepted
time: 24ms
memory: 37564kb

input:

17
25
20
38358167 8720134 92898945
702923 6723166 951852
51931279 1664762 89442443
9661230 8760543 3...

output:

38252825171
244518
3634
36115971843
35626320
145244
1792413
25344781224
1341
216331886
37402
2392212...

result:

ok 25 lines

Test #18:

score: 5
Accepted
time: 109ms
memory: 169284kb

input:

18
25
20
29 74 0
0 9 14
7 19 5
24 95 4
90 76 2
0 1 27
0 0 4
96 45 3
47 4 9
3 9 71
1 27 3
9 28 8
71 6...

output:

13093
15162
29914
34921975
86400517
25166164745
36716
298917925476
39883207618
17452070
8576942800
1...

result:

ok 25 lines

Test #19:

score: 5
Accepted
time: 107ms
memory: 169280kb

input:

19
25
20
20492 63749 3286
24644 1095 616
6467 4054 6506
2736 9046 5769
28408 4905 776
5147 154 129
6...

output:

9410268
19123
4666380
2549971
2605899496
22187841686
2601
2622042567
2507
2537133
359737
24384053054...

result:

ok 25 lines

Test #20:

score: 5
Accepted
time: 115ms
memory: 169280kb

input:

20
25
20
42717191 40935557 10935392
110410 19836885 11366338
49174556 4497680 2842944
612553686 1544...

output:

105017560917
291680
1790
19634
18576695703
1309020
143587
179459627
9025598
202570462165
1629679316
...

result:

ok 25 lines

Extra Test:

score: 0
Extra Test Passed