QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#629980#8024. Fountainsucup-team3161#AC ✓574ms58764kbC++141.0kb2024-10-11 15:49:392024-10-11 15:49:42

Judging History

你现在查看的是最新测评结果

  • [2024-10-11 15:49:42]
  • 评测
  • 测评结果:AC
  • 用时:574ms
  • 内存:58764kb
  • [2024-10-11 15:49:39]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define eb emplace_back
#define fi first
#define se second
const int N=105;
int n,m,a[N];ll s,ans[N],b[N][N];pii o[N];map<vi,ll> dp[N][N];
int main()
{
	scanf("%d",&n);for(int i=0;i<n;++i) scanf("%d",&a[i]);
	for(int i=0;i<n;++i)
	{
		b[i][i]=a[i];
		for(int j=i+1;j<n;++j) b[i][j]=b[i][j-1]+a[j];
	}
	for(int i=0;i<n;++i) for(int j=i;j<n;++j) s+=b[i][j];
	for(int i=0;i<n;++i) for(int j=i;j<n;++j) o[++m]={i,j};
	sort(o+1,o+m+1,[](pii x,pii y) {return b[x.fi][x.se]>b[y.fi][y.se];});
	vi z(n);fill(z.begin(),z.end(),n);dp[0][0][z]=0;
	for(int i=1;i<=m;++i)
	{
		auto [l,r]=o[i];
		for(int j=1;j<=i;++j) for(int i1=0;i1<i;++i1)
			for(auto [z,w]:dp[i1][j-1])
			{
				vi z1=z;
				for(int k=0;k<=l;++k) if(z1[k]>r)
					w+=b[l][r]*(z1[k]-r),z1[k]=r;
				ans[j]=max(ans[j],w);dp[i][j][z1]=max(dp[i][j][z1],w);
			}
	}
	for(int i=1;i<=m;++i) printf("%lld\n",s-ans[i]);return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 4348kb

input:

1
1

output:

0

result:

ok 1 number(s): "0"

Test #2:

score: 0
Accepted
time: 0ms
memory: 4336kb

input:

2
13 24

output:

26
13
0

result:

ok 3 number(s): "26 13 0"

Test #3:

score: 0
Accepted
time: 0ms
memory: 4312kb

input:

3
6 4 7

output:

33
21
12
8
4
0

result:

ok 6 numbers

Test #4:

score: 0
Accepted
time: 0ms
memory: 4260kb

input:

1
1000000000

output:

0

result:

ok 1 number(s): "0"

Test #5:

score: 0
Accepted
time: 1ms
memory: 4616kb

input:

3
1000000000 1000000000 1000000000

output:

6000000000
4000000000
3000000000
2000000000
1000000000
0

result:

ok 6 numbers

Test #6:

score: 0
Accepted
time: 1ms
memory: 4348kb

input:

4
91 24 13 45

output:

402
267
185
137
89
52
39
26
13
0

result:

ok 10 numbers

Test #7:

score: 0
Accepted
time: 1ms
memory: 4416kb

input:

4
41 38 27 23

output:

386
279
220
168
130
92
69
46
23
0

result:

ok 10 numbers

Test #8:

score: 0
Accepted
time: 1ms
memory: 4632kb

input:

4
96 79 21 85

output:

799
544
386
276
180
84
63
42
21
0

result:

ok 10 numbers

Test #9:

score: 0
Accepted
time: 1ms
memory: 4344kb

input:

4
64 14 13 21

output:

246
178
124
96
74
52
39
26
13
0

result:

ok 10 numbers

Test #10:

score: 0
Accepted
time: 1ms
memory: 4404kb

input:

4
37 39 74 87

output:

691
465
374
296
222
148
111
74
37
0

result:

ok 10 numbers

Test #11:

score: 0
Accepted
time: 1ms
memory: 4584kb

input:

4
13 81 35 93

output:

634
378
192
122
87
52
39
26
13
0

result:

ok 10 numbers

Test #12:

score: 0
Accepted
time: 1ms
memory: 4360kb

input:

4
99 79 63 38

output:

832
582
436
310
231
152
114
76
38
0

result:

ok 10 numbers

Test #13:

score: 0
Accepted
time: 1ms
memory: 4436kb

input:

5
960291817 979089901 937338124 900872248 921429110

output:

21385776793
16901343929
13964074226
11201545674
9358687454
8338338015
7378046198
6420151212
5462256226
4504361240
3603488992
2702616744
1801744496
900872248
0

result:

ok 15 numbers

Test #14:

score: 0
Accepted
time: 3ms
memory: 4844kb

input:

6
993702683 956722344 945667651 937295260 920868105 928898923

output:

35868957528
28436304068
22822642178
20706312438
17869309485
15101698227
13229480240
12173997672
11217275328
10260552984
9306512942
8361186864
7415860786
6470534708
5525208630
4604340525
3683472420
2762604315
1841736210
920868105
0

result:

ok 21 numbers

Test #15:

score: 0
Accepted
time: 17ms
memory: 7024kb

input:

7
945176955 913718431 912448136 950992979 912981052 948181396 946164955

output:

53191717275
44501626672
37196960404
30994801907
28115745758
25262766821
22420682553
20464902679
17728362180
16702886635
15686968934
14733738032
13787573077
12842396122
11897219167
10952042212
10039061160
9126080108
8213099056
7300118004
6387136952
5474688816
4562240680
3649792544
2737344408
18248962...

result:

ok 28 numbers

Test #16:

score: 0
Accepted
time: 88ms
memory: 16512kb

input:

8
981030736 935503389 905831819 997942942 961662963 971971316 916753883 950806024

output:

79199943766
66124947723
55282784027
49174383156
43597634412
38264451054
35955429554
33070440665
30276989931
27497054921
24778815503
22787082461
21667782589
20610496507
19570420909
18555338032
17574307296
16593829702
15632166739
14670503776
13708840813
12747177850
11830423967
10913670084
9996916201
9...

result:

ok 36 numbers

Test #17:

score: 0
Accepted
time: 435ms
memory: 58468kb

input:

9
974093639 939349722 984374605 983016315 948537831 977490893 925808537 994566031 909335534

output:

112051943626
93894263739
80259662557
70824539351
63143041079
57193287893
51513369219
47563265799
44614216854
41692201370
38815346711
36036588096
33347324800
30610843973
28621711911
27519788224
26420168934
25347466127
24254201388
23224801900
22207041668
21258503837
20309966006
19361428175
18422078453...

result:

ok 45 numbers

Test #18:

score: 0
Accepted
time: 570ms
memory: 58764kb

input:

9
988753260 930587988 938840994 910709497 931244663 913556182 951019678 937308985 960855700

output:

109705038951
91824947725
78840163566
69540422753
62047209577
56412747531
50870386768
46982501373
44149437333
41299739669
38461654997
35666675405
32850152423
30109483877
28187772477
27103286973
26081421062
25060171928
24047871953
23043653299
22056145642
21118836657
20181527672
19244218687
18313630699...

result:

ok 45 numbers

Test #19:

score: 0
Accepted
time: 522ms
memory: 58760kb

input:

9
948966946 921831063 949684848 947683626 928119557 989949389 935833156 994196727 991744214

output:

111572863297
93514523880
80002832720
70638051681
62973940521
57197371484
51604732268
47681023654
44770606631
41812485545
38969434667
36130105643
33327511201
30566109817
28609812354
27495422224
26443524746
25405592085
24370226064
23378481850
22400943217
21424122486
20447301755
19472482246
18536649090...

result:

ok 45 numbers

Test #20:

score: 0
Accepted
time: 447ms
memory: 58432kb

input:

9
909583482 981756179 985225343 922969840 971691040 997861742 932857966 921931511 962043515

output:

111442653890
92977899586
79614492881
70376796695
62594675067
56787258411
51135016807
47266411565
44397725701
41532472770
38687773444
35904010406
33165342766
30452307548
28488795190
27341123671
26270339273
25207473755
24173527212
23156148520
22173531025
21200561055
20227591085
19254621115
18331651275...

result:

ok 45 numbers

Test #21:

score: 0
Accepted
time: 442ms
memory: 58748kb

input:

9
936231783 985899313 992363534 974752529 929476249 991887369 943524491 907507864 930742311

output:

111525437808
93408169047
79562357436
70316727742
62554098470
56855542632
51298951532
47572194320
44526633227
41616900047
38713260888
35929195386
33196219527
30461524377
28500704695
27459978283
26365915405
25297523718
24269619722
23247703782
22255340248
21288581310
20321822372
19355063434
18418831651...

result:

ok 45 numbers

Test #22:

score: 0
Accepted
time: 506ms
memory: 58748kb

input:

9
942339391 953843426 935935572 908883684 928317637 976125617 996356822 942235350 928538251

output:

110485258497
92469415445
78946571586
69672104067
62104075429
56429014253
50790810595
46978993730
44147030091
41328739088
38529459764
35718643877
32973453497
30219200165
28334729465
27255740575
26220381479
25196447882
24200091060
23219195746
22257526443
21302156918
20346787393
19391417868
18449078477...

result:

ok 45 numbers

Test #23:

score: 0
Accepted
time: 535ms
memory: 58756kb

input:

9
967005685 953100814 986282117 961586053 919175900 935551614 918740864 933101783 999990728

output:

110767245170
93217982963
79651185350
70372375211
62827564823
57195267467
51611586776
47731197422
44773359668
41845807718
38961049559
36088298294
33219219133
30462996541
28514624252
27472875679
26435422862
25406730592
24398875562
23398688574
22406365888
21414043202
20432676598
19468403146
18515302332...

result:

ok 45 numbers

Test #24:

score: 0
Accepted
time: 425ms
memory: 58468kb

input:

9
972340307 935264581 978461803 957503414 978320463 953606628 948586340 929436733 918566572

output:

111231338825
93003676042
79528944023
70229832567
62695516763
56903140939
51218712505
47374728474
44488774193
41616263951
38757135805
35948038585
33138271486
30396415444
28537541978
27452719598
26408963080
25402933107
24400442749
23409760395
22429393157
21471889743
20514386329
19556882915
18608296575...

result:

ok 45 numbers

Test #25:

score: 0
Accepted
time: 574ms
memory: 58456kb

input:

9
968387461 966238574 912201654 906323852 914716857 920514014 984214382 921472420 991332642

output:

109668394536
92007807149
78668776041
69650523239
62136762327
56450680909
50847580729
47021970605
44112035744
41307825322
38525511278
35739445707
32914379897
30195408341
28204596499
27079703267
26003360729
25003039373
24009477199
23033063049
22066824475
21100585901
20134347327
19207874866
18286402446...

result:

ok 45 numbers

Test #26:

score: 0
Accepted
time: 478ms
memory: 58436kb

input:

9
956661351 980048665 908526544 951642594 951220073 979978790 962820592 971016525 933744231

output:

111520453587
93450889752
80175492714
70679037360
62896243503
57138057102
51317234460
47397039800
44457103430
41589839726
38803985846
35973829342
33235556824
30468472516
28555149814
27476915884
26434377238
25390688047
24344392169
23301853523
22339032931
21382371580
20425710229
19469048878
18517828805...

result:

ok 45 numbers

Test #27:

score: 0
Accepted
time: 478ms
memory: 58448kb

input:

9
108 100 110 101 110 108 104 110 105

output:

12389
10328
8855
7832
6976
6314
5662
5246
4939
4620
4313
4008
3697
3397
3178
3045
2916
2796
2676
2558
2442
2337
2232
2127
2023
1919
1815
1711
1607
1506
1405
1304
1203
1102
1001
900
800
700
600
500
400
300
200
100
0

result:

ok 45 numbers

Test #28:

score: 0
Accepted
time: 458ms
memory: 58432kb

input:

9
101 104 106 102 107 100 104 108 102

output:

12172
10127
8683
7659
6811
6175
5547
5131
4822
4514
4212
3905
3603
3301
3097
2982
2870
2755
2643
2531
2423
2321
2219
2117
2015
1913
1811
1709
1607
1506
1405
1304
1203
1102
1001
900
800
700
600
500
400
300
200
100
0

result:

ok 45 numbers

Test #29:

score: 0
Accepted
time: 0ms
memory: 4356kb

input:

4
3 3 8 9

output:

63
39
30
24
18
12
9
6
3
0

result:

ok 10 numbers

Test #30:

score: 0
Accepted
time: 524ms
memory: 58412kb

input:

9
10 8 2 1 1 5 10 1 9

output:

466
367
304
260
220
190
164
144
126
116
106
96
86
77
68
60
54
48
42
38
34
30
28
26
24
22
20
18
16
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
0

result:

ok 45 numbers

Test #31:

score: 0
Accepted
time: 525ms
memory: 58492kb

input:

9
1414 1327 1169 1356 296 978 1980 1753 1601

output:

149428
118612
100088
87598
78371
70235
63373
57891
53649
50128
46090
42583
39077
36040
33386
31101
29145
27189
25233
23632
22031
20430
19016
17602
16188
14774
13395
12121
10847
9678
8509
7340
6171
5002
3833
2664
2368
2072
1776
1480
1184
888
592
296
0

result:

ok 45 numbers

Extra Test:

score: 0
Extra Test Passed