QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#356489#7199. Bombvme50AC ✓64ms144360kbC++17984b2024-03-17 21:22:472024-03-17 21:22:48

Judging History

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

  • [2024-03-17 21:22:48]
  • 评测
  • 测评结果:AC
  • 用时:64ms
  • 内存:144360kb
  • [2024-03-17 21:22:47]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N=3e3+5;
int n,a[N];ll b[N],s[N],dp1[N][N],dp2[N][N];
void W(ll &x,ll y) {x=min(x,y);}
ll sqr(int x) {return 1ll*x*x;}
int main()
{
	while(~scanf("%d",&n))
	{
		for(int i=1;i<=n;++i) scanf("%d",&a[i]);
		b[0]=b[n]=1e18;for(int i=1;i<n;++i) b[i]=sqr(a[i]-a[i+1]);
		for(int i=1;i<=n;++i) s[i]=s[i-1]+b[i-1];
		for(int i=1;i<=n;++i) for(int j=i;j<=n;++j) 
			dp1[i][j]=dp2[i][j]=1e18;dp1[1][1]=dp2[1][1]=0;
		for(int i=1;i<=n;++i)
		{
			for(int j=n-1;j>=i;--j) W(dp2[i][j],dp2[i][j+1]);	
			for(int j=i;j<=n;++j)
			{
				if(i<j) W(dp1[i][j],dp2[i][j]+s[j-1]-s[i]);
				if(j<n) W(dp1[i][j+1],dp1[i][j]+b[j]);
				if(i<j) W(dp2[i+1][j],dp2[i][j]+b[i]);
			}
			for(int j=n,t=n;j>i;--j)
			{
				while(t && a[t]>a[j]*2-a[i]) --t;
				W(dp2[j][t],dp1[i][j]+sqr(a[i]-a[j]));
				if(t<n) W(dp2[j][t+1],dp1[i][j]+sqr(a[j]-a[t+1]));
			}
		}printf("%lld\n",dp2[n][n]);
	}return 0;
}

这程序好像有点Bug,我给组数据试试?

詳細信息

Test #1:

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

input:

5
1 4 5 6 10
3
1 2 6

output:

51
33

result:

ok 2 tokens

Test #2:

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

input:

18
1 2 3 6 11 23 47 106 235 551 1301 3159 7741 19320 48629 123867 317955 823065
5
1 5 6 7 11
2
1 1000000
3
1 12345 1000000
4
1 2 3 1000000

output:

554621353432
59
1999996000002
1951077172386
1999988000020

result:

ok 5 tokens

Test #3:

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

input:

5
1 2 5 6 7
5
1 4 5 7 10
5
1 2 5 7 10
5
1 4 5 7 10
5
1 2 5 6 7
5
1 4 5 7 10
5
1 2 5 6 7
5
1 2 5 6 7
5
2 5 6 7 9
5
2 5 6 7 9
5
1 4 5 7 10
5
2 3 5 6 9
5
2 5 6 7 9
5
1 2 5 6 7
5
2 3 6 8 9
5
1 2 5 7 10
5
2 3 5 6 9
5
1 4 5 7 10
5
1 2 5 6 7
5
1 2 5 7 10
5
2 5 6 7 9
5
1 2 5 7 10
5
1 4 5 7 10
5
2 3 6 8 9
5
...

output:

21
37
37
37
21
37
21
21
27
27
37
24
27
21
24
37
24
37
21
37
27
37
37
24
27
27
27
27
24
24
37
27
24
24
27
21
21
37
37
21
24
27
24
27
21
27
37
37
37
27
37
21
24
37
37
24
24
21
27
24
37
27
21
37
37
24
27
21
27
37
21
37
37
24
37
24
37
37
21
37
21
27
21
24
24
27
27
24
37
24
24
27
37
24
27
37
24
21
24
24

result:

ok 100 tokens

Test #4:

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

input:

10
6 8 24 41 42 43 66 81 83 99
10
3 17 28 51 54 58 65 71 77 98
10
31 55 56 59 63 67 78 84 89 93
10
31 55 56 59 63 67 78 85 89 93
10
11 12 13 29 36 50 74 75 94 95
10
2 16 21 23 45 47 69 70 72 96
10
15 16 19 47 49 72 73 79 86 92
10
31 34 55 56 59 63 67 78 84 93
10
1 23 35 45 48 62 64 69 70 90
10
5 22 ...

output:

2158
2429
1392
1396
2225
2495
2233
1259
2188
2130
2027
2529
1418
1988
2188
2000
1428
2515
3627
2327
1348
2051
2158
1462
1988
2045
2083
2291
1462
2345
2333
1396
2258
2142
1428
2051
1538
2002
2363
2173
2276
2465
2118
1902
1538
2051
2069
2784
2118
2529
3579
2394
1196
2083
2033
2129
2129
2345
3579
2427
...

result:

ok 100 tokens

Test #5:

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

input:

10
2 10 73 77 215 499 529 571 593 852
10
269 413 549 684 713 721 768 779 844 992
10
54 136 371 391 435 520 623 655 931 954
10
17 46 131 179 194 308 457 525 631 750
10
29 67 130 146 541 749 778 781 880 916
10
36 217 235 328 407 418 503 612 643 901
10
284 386 406 515 677 796 802 833 866 874
10
86 109 ...

output:

278307
127252
284024
112244
372930
228686
94487
367948
230682
110055
236945
212852
117149
180383
169672
129090
223211
350467
223211
251629
223880
200504
120618
258344
226727
143334
311723
196499
149390
184072
421558
174485
201111
94619
179006
212317
266909
379236
229074
169674
179668
186173
334020
2...

result:

ok 100 tokens

Test #6:

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

input:

10
234 1085 1165 2425 4774 5515 5660 6722 8376 9226
10
558 1144 1833 2926 5083 5747 8416 8551 8552 9492
10
757 1668 2074 4883 5826 6140 6197 6960 8387 9369
10
1429 2696 2732 3715 3735 4337 4800 7094 7899 9558
10
622 711 779 2753 3953 5199 5617 5761 6690 9918
10
1636 1817 1959 4123 4737 6215 6612 703...

output:

20117841
23089739
22803795
18523085
31256882
14972369
16051813
16867644
18978629
22312179
11208012
19757866
27561421
16810245
47709791
25072176
41010814
20778228
22773397
29475017
20311218
16124575
9620078
19709701
23763072
22358063
27350716
35374800
18824986
11186036
16111364
28259973
33547152
1459...

result:

ok 100 tokens

Test #7:

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

input:

10
15102 15569 20429 39036 40183 50253 50597 80348 92752 99844
10
5112 22851 40822 48311 52322 53328 63940 66321 77702 79960
10
22259 24157 41964 62693 68027 74281 75000 80325 85585 89234
10
28679 29743 37428 41965 45016 51421 65868 80006 90474 97956
10
16339 16974 36490 38344 42315 45264 45331 6815...

output:

2467883689
1421776819
1317493994
952457182
2110941514
3498817531
3911460217
3776248915
2304622300
2025219240
3789833624
2284992758
1140801935
2635444904
1758354112
2862924856
3590102212
2199706444
1306006038
2754838930
1938543817
2130678728
2679290464
3666983437
2085193355
2292440590
640716760
30843...

result:

ok 100 tokens

Test #8:

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

input:

10
54830 103760 137063 148177 230922 340036 772500 773979 833767 907570
10
2633 239221 305170 332102 381044 504166 577878 650076 765750 874519
10
111304 142793 173210 188447 491726 751912 753363 851544 876513 888684
10
369354 380010 571580 576847 704957 732594 875741 894809 931421 959770
10
144584 3...

output:

405453253512
191365523338
264215173821
121559109781
192607669544
75171490906
152365413336
170394900531
269673537856
155189420290
171686170057
388468588211
433470745331
195943045489
131774604508
78522276081
144945094106
175006878872
217170408787
226024298243
204048657380
292524086250
205057671088
260...

result:

ok 100 tokens

Test #9:

score: 0
Accepted
time: 60ms
memory: 143716kb

input:

3000
284 696 1219 1457 1583 1640 1892 3902 4164 4474 4506 4601 4773 4872 5045 5278 5368 5631 5653 6100 6937 7022 7571 7628 8157 8293 8553 9415 9436 9784 9882 9902 10626 10710 11180 11202 11305 11769 12458 13032 13210 13222 14191 14815 15741 15849 16257 16499 16926 17203 17228 17628 18571 19098 19205...

output:

1048797103

result:

ok "1048797103"

Test #10:

score: 0
Accepted
time: 64ms
memory: 143916kb

input:

2999
165 471 660 946 1243 1416 1912 1954 2108 2299 2699 3318 3936 4169 4201 4205 4735 5554 6080 6524 6913 7352 7412 7589 8201 8253 8577 8630 8932 9608 9672 9999 10191 10512 10692 11013 11204 11399 11461 11585 12146 12332 12575 13111 14051 14250 14450 14675 14737 14863 14867 14990 15074 15267 15911 1...

output:

984219851

result:

ok "984219851"

Test #11:

score: 0
Accepted
time: 56ms
memory: 143728kb

input:

3000
142 833 1098 1561 1789 2148 2241 4472 4854 5010 5576 5873 6423 6928 7239 7612 7901 8357 8935 9070 9088 9151 9204 9434 9465 9497 9503 9772 9917 10126 10221 10735 11264 11290 12074 12093 12390 12990 13072 13094 13706 13995 14226 14337 14676 14902 15178 16187 16305 16805 18601 18908 18926 19199 19...

output:

1035868827

result:

ok "1035868827"

Test #12:

score: 0
Accepted
time: 59ms
memory: 144360kb

input:

2998
658 1025 1035 1065 1432 1742 1962 2389 3008 3977 4016 4095 4269 4287 4341 4353 5597 5741 5835 6037 6279 7177 7620 7816 7977 8255 8526 8819 8823 8833 9465 9648 10165 11086 11200 12049 12602 12720 13018 13340 13434 14301 14415 14680 14880 15821 16136 16439 16451 16670 16969 17550 18624 18985 1905...

output:

1026736856

result:

ok "1026736856"

Test #13:

score: 0
Accepted
time: 47ms
memory: 135824kb

input:

2789
167 296 998 1130 2569 3119 3664 3808 4362 4819 4890 5882 5902 6316 6383 6632 7045 7140 7143 7859 7939 7958 8066 9274 9973 10064 10542 10547 10866 10948 11391 11412 11481 11654 12761 12888 12983 13675 13697 14429 14515 14833 14917 15000 15435 15449 16538 16849 16930 17869 18128 18140 18885 19733...

output:

1080462001

result:

ok "1080462001"

Test #14:

score: 0
Accepted
time: 2ms
memory: 8096kb

input:

50
67 109 300 318 333 472 541 591 596 659 766 832 858 915 1002 1098 1114 1221 1256 1306 1315 1541 1558 1683 1749 1798 1838 1877 1891 1902 1907 1934 1946 2090 2276 2314 2328 2354 2404 2457 2481 2725 2763 2881 2973 3004 3006 3058 3135 3167
50
29 221 290 311 320 336 467 569 611 822 910 930 938 939 1016...

output:

546914
586970
617718
621484
610800
518739
581617
789900
570475
786434
555037
577385
613568
489789
604261
522051
522014
590350
586315
533438
467059
549991
550446
868245
885380
691793
604433
407431
787566
499686
568237
571880
574485
453799
699811
884550
606889
586114
669451
701720
697659
514465
626219...

result:

ok 60 tokens

Test #15:

score: 0
Accepted
time: 2ms
memory: 8152kb

input:

50
72 102 113 174 179 227 438 585 604 629 727 835 856 1037 1210 1579 1607 1625 1630 1676 1694 1812 1884 1931 1945 1953 1993 2024 2076 2084 2179 2266 2336 2352 2383 2384 2407 2478 2562 2607 2694 2769 2858 2905 2940 2942 2946 2982 3052 3232
50
32 88 123 183 195 336 393 414 463 565 583 661 666 693 768 ...

output:

651410
715895
602715
650890
574813
557024
903110
495114
384872
576695
519117
560761
570519
594881
770980
736408
699581
754373
598687
691339
605166
472594
601148
791575
551684
447509
487814
580147
470042
559362
823417
652279
616677
486164
626341
713301
669424
521142
621959
589767
610810
471601
545177...

result:

ok 60 tokens

Test #16:

score: 0
Accepted
time: 2ms
memory: 8224kb

input:

50
22 69 84 148 231 236 462 532 545 649 700 778 785 820 913 945 957 1037 1131 1215 1241 1375 1418 1489 1528 1564 1698 1717 1760 1818 1890 1963 2060 2067 2070 2071 2216 2272 2324 2377 2393 2473 2475 2566 2590 2755 2903 3039 3170 3200
50
67 118 176 194 228 317 359 408 520 544 569 577 659 711 720 786 8...

output:

464352
560544
978870
550979
533530
649007
620108
508733
496051
484877
540212
569524
548622
585737
552316
592062
582383
417431
420238
611344
499316
586144
690782
780779
610137
709044
487396
591977
603808
502241
448924
496705
562938
414233
585230
692928
649019
603853
595973
632109
483348
666089
651811...

result:

ok 60 tokens

Test #17:

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

input:

100
224 809 888 920 970 1832 1950 2101 2201 2277 2529 2595 2610 2920 3335 3600 3624 3862 4775 5025 5096 5339 5517 5785 7232 7317 7483 8233 8290 8678 8980 9006 9200 9249 9433 9499 9576 9828 10300 10404 10489 10759 11392 11636 12213 12350 13021 13389 13934 14217 14250 14507 14757 15516 15695 15851 166...

output:

29754702
31406338
27354291
31740336
34496310
25677445
25889522
29197939
30752697
45297341
33545782
26231606
30916272
43299157
24055751
36406291
24361691
30919003
28106136
34091351
33289838
28594649
35431095
31674947
29802962
29104765
34060931
35185764
27777841
27577561

result:

ok 30 tokens

Test #18:

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

input:

100
1353 1474 2024 2777 2818 3510 3605 3857 4496 5345 5442 5450 5509 5698 7511 7853 7995 9152 9834 9874 10075 10419 10543 11153 11170 11244 11436 11704 11803 11856 12192 12911 13578 14066 14496 14585 14658 14794 15250 15275 15984 15999 16108 16114 16269 16486 17324 18156 18252 18350 18797 19303 1940...

output:

26840158
29570285
30028028
31273482
32826757
32449945
36601484
34506754
24318830
34843912
31470591
29167437
32937108
30397424
35000970
29899489
30619288
28392584
32648025
37821485
41688557
40018670
26703842
29917542
31489685
33713562
28961796
31163060
31188693
29671362

result:

ok 30 tokens

Test #19:

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

input:

100
4454 4622 5224 9400 11520 15393 16524 20666 27646 27844 29378 32494 32830 38418 40016 42920 43250 44524 47890 49064 52245 56677 57645 59739 68078 79391 81083 82016 82892 83032 84965 85157 87427 87964 89355 91919 96353 97909 98070 99387 108771 113219 114102 118664 119211 120726 122475 123871 1244...

output:

3437425116
2967553034
3016904513
3267195260
2661829568
2589354068
3085922459
3210078778
3044509200
3294359710
2958493596
2789412227
2918706457
3570829054
2651893413
2935983552
3561452292
3062071969
3127743867
3281295575
3402673799
3343342332
3011753293
2918153419
2951720683
3728772060
3254457132
371...

result:

ok 30 tokens

Test #20:

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

input:

100
13803 17400 35176 40188 50993 65731 74776 84380 97817 99945 115640 125087 129584 131253 142019 179994 198499 203782 207487 218176 223904 227463 244562 250972 288888 304877 307093 321334 322190 325929 338208 341873 346832 351971 370465 377535 388661 390167 413387 420841 420860 422536 430767 45577...

output:

26577162955
27603803499
28329803126
28218306592
31571801885
24221947128
28936606689
28257187419
31313614859
29837183398
28333395650
30563095436
29550838895
29246341618
28600642900
24070149867
27700235520
32824533009
32460765350
25520501996
24926068442
29831859611
29673495329
31374576685
27941610167
...

result:

ok 30 tokens

Test #21:

score: 0
Accepted
time: 19ms
memory: 53968kb

input:

1000
450 476 491 523 567 1539 1709 1824 1900 1917 2084 2207 2224 2233 2288 2323 2569 2604 2737 3292 3826 4014 5325 5515 6022 6030 6232 6535 6796 7123 7163 7394 7725 7842 7865 7963 8159 8194 8263 8310 8428 9008 9396 9461 9662 9999 10664 10839 10884 11098 11183 11487 11539 11540 11936 12086 12588 1269...

output:

172130770
177002640
201877459

result:

ok 3 tokens

Test #22:

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

input:

1000
1140 1223 1324 1460 1900 2123 2260 2367 2371 2697 2900 3113 3127 3286 3535 3916 4153 4390 4448 4813 4980 5095 5369 5727 5923 5978 6157 6184 6559 6655 6824 6886 7029 7495 7695 7729 7732 7754 8261 8324 8392 8434 9524 9747 9839 10111 10265 10294 10354 10420 10590 10669 10776 10862 11004 11086 1123...

output:

176935080
173698843
178766127

result:

ok 3 tokens

Test #23:

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

input:

20
3 15 17 19 20 21 23 25 30 43 53 55 62 63 69 79 84 85 93 96
20
9 12 17 20 29 33 36 52 55 62 63 69 70 75 76 79 85 92 93 96
20
1 6 7 10 13 16 32 34 39 44 47 48 51 56 64 71 89 90 94 95
20
1 6 7 10 13 16 32 34 39 44 47 48 51 56 64 71 89 90 94 95
20
3 6 11 15 17 19 21 23 25 30 43 53 62 63 69 79 84 86 9...

output:

1157
927
1440
1440
926
1077
1077
1026
1193
2456
1041
1183
1182
3277
1182
1191
1085
1091
1083
1442
1440
1216
1121
1381
1083
1230
1214
1346
1041
1005
927
1157
2465
1079
3295
1216
2490
1295
1218
1303
1356
1015
926
1014
1104
1205
1183
1167
1015
1183
1104
1381
1082
1381
1167
1422
1216
1259
1077
1121
1217...

result:

ok 150 tokens

Test #24:

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

input:

20
4 17 25 26 35 36 44 46 48 53 57 58 62 63 69 79 81 83 88 95
20
2 16 20 22 23 27 28 33 34 56 59 64 70 71 72 90 91 93 94 100
20
3 5 6 7 8 11 15 21 24 26 35 37 50 55 63 65 68 73 75 81
20
3 4 7 11 17 21 24 26 35 44 48 50 53 63 68 75 79 81 88 95
20
5 6 8 9 10 12 13 15 31 37 43 52 55 65 73 77 78 85 96 9...

output:

985
2134
741
816
1258
741
1934
1505
722
1383
1246
818
722
1469
1148
727
1411
816
2122
1148
841
2056
669
1437
1426
1449
2122
1449
1449
1386
2187
1479
1449
958
856
764
2187
1386
971
1364
1125
769
1364
841
2134
669
958
985
1059
769
1148
741
1690
1659
730
741
769
2122
741
1054
1437
1056
2187
1227
715
11...

result:

ok 150 tokens

Test #25:

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

input:

20
6 14 16 17 34 35 36 37 38 45 48 54 56 60 61 65 81 82 91 100
20
1 4 5 7 15 19 32 33 42 43 47 53 63 67 68 79 87 88 93 99
20
10 14 17 34 35 36 37 38 45 48 54 56 58 60 61 65 70 82 91 100
20
2 13 18 24 28 31 39 49 51 52 55 59 62 66 75 77 84 86 89 94
20
6 8 9 14 16 17 21 25 34 35 36 37 54 56 60 61 81 8...

output:

1468
1121
1228
891
1672
890
845
1162
1365
1388
1041
1202
1262
803
1107
1211
1211
942
1479
814
1199
814
1479
1107
915
942
1250
1280
1886
1301
1198
1672
1211
869
1211
1283
1262
1230
1262
1162
1497
1474
1188
1874
1211
1479
812
1456
1301
1205
1880
1097
1262
1880
812
1211
1181
1468
1174
1388
1308
1457
14...

result:

ok 150 tokens

Test #26:

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

input:

30
2 4 6 7 20 25 29 32 34 35 41 44 46 48 50 52 53 56 66 70 72 80 81 84 87 88 90 91 97 100
30
1 13 14 16 23 27 32 33 34 40 42 45 46 48 53 59 62 64 66 67 70 72 73 76 79 81 86 90 91 98
30
2 3 4 6 7 20 22 25 29 32 35 41 44 47 48 50 52 56 57 66 70 80 83 84 87 88 90 97 99 100
30
1 2 4 6 7 23 27 32 33 34 4...

output:

930
769
975
1010
932
876
944
1022
1005
1017
1017
910
1010
770
1022
1115
818
752
752
1078
1111
816
974
692
1100
789
748
808
769
932
944
1111
1028
1010
944
1111
795
818
944
759
755
944
813
964
1070
776
1070
943
1109
964
1070
647
1014
776
1063
748
1100
910
943
680
752
759
816
795
813
932
908
755
1024
9...

result:

ok 100 tokens

Test #27:

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

input:

30
2 5 7 8 12 15 16 17 18 27 28 30 32 35 43 44 45 51 53 54 57 60 64 73 74 77 82 87 88 91
30
1 2 7 8 9 12 14 16 18 28 32 35 43 44 45 51 53 54 57 62 65 70 73 74 77 86 87 88 91 93
30
11 21 22 23 29 31 38 41 42 48 49 55 58 61 68 69 71 75 76 78 79 80 81 84 89 90 94 98 99 100
30
1 2 7 8 9 14 16 18 28 32 3...

output:

653
732
671
892
825
696
637
892
826
634
669
677
707
748
691
682
611
925
657
728
810
712
762
642
761
628
677
867
892
748
691
602
690
761
732
769
835
759
925
892
583
682
691
634
925
723
692
810
690
762
641
583
682
671
689
892
669
739
597
641
826
606
719
769
637
761
739
778
835
612
835
825
729
867
612
...

result:

ok 100 tokens

Test #28:

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

input:

30
5 8 18 22 24 25 31 36 37 38 39 40 47 52 56 57 61 63 71 72 74 75 80 81 83 86 88 94 98 100
30
5 8 17 18 22 24 25 31 36 37 38 40 47 52 56 57 61 63 68 71 72 74 75 83 86 88 90 94 98 100
30
5 8 9 17 18 22 24 25 31 37 38 40 47 52 56 57 61 63 68 71 72 74 75 83 86 88 90 94 98 100
30
3 4 7 9 17 18 22 25 28...

output:

752
701
678
721
674
678
701
706
701
679
727
658
674
674
742
763
763
679
678
643
725
655
824
667
684
725
622
643
651
815
959
815
752
663
725
639
737
719
797
701
696
797
669
697
727
815
672
963
678
665
653
663
707
725
725
725
670
824
665
725
639
639
730
644
701
640
730
653
701
862
730
725
696
586
843
...

result:

ok 100 tokens

Extra Test:

score: 0
Extra Test Passed