QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#811815#2175. Growing Vegetables is Fun 4sichengzhou#100 ✓52ms10320kbC++17529b2024-12-13 01:58:312024-12-13 01:58:33

Judging History

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

  • [2024-12-13 01:58:33]
  • 评测
  • 测评结果:100
  • 用时:52ms
  • 内存:10320kb
  • [2024-12-13 01:58:31]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=2e5+5;
int n;
LL a[N],s[N],t[N],f[N],g[N],b[N];
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    for(int i=1;i<=n;i++)
    {
        s[i]=s[i-1]+max(0ll,a[i-1]+1-a[i]);
    }
    for(int i=n;i>=1;i--)
    {
        t[i]=t[i+1]+max(0ll,a[i+1]+1-a[i]);
    }
    LL ans=2e18;
    for(int i=1;i<=n;i++)
    {
        ans=min(ans,max(s[i],t[i]));
    }
    cout<<ans<<'\n';
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 40
Accepted

Test #1:

score: 40
Accepted
time: 1ms
memory: 5664kb

input:

2
569756508 265577686

output:

0

result:

ok single line: '0'

Test #2:

score: 40
Accepted
time: 1ms
memory: 5620kb

input:

2
905574077 905574077

output:

1

result:

ok single line: '1'

Test #3:

score: 40
Accepted
time: 1ms
memory: 5712kb

input:

3
970577574 477262134 791905208

output:

314643075

result:

ok single line: '314643075'

Test #4:

score: 40
Accepted
time: 1ms
memory: 5664kb

input:

3
634647532 634647532 634647532

output:

1

result:

ok single line: '1'

Test #5:

score: 40
Accepted
time: 1ms
memory: 5684kb

input:

1999
835109617 608292283 618117484 497958957 611607015 70168164 477454019 70333286 821931315 104232697 234095331 41806748 813743448 676090182 776662569 441747966 907663428 993530698 7954955 202095258 789793212 448943101 515564795 68382202 507155724 819747128 339256745 491780118 461177551 81438287 48...

output:

166120578451

result:

ok single line: '166120578451'

Test #6:

score: 40
Accepted
time: 1ms
memory: 3668kb

input:

2000
170529959 623329315 965664042 467968363 328879023 420592360 541565899 974044680 404331678 353781756 297737606 500439608 76409803 603659940 764189869 595344000 91573695 787151490 977013526 250496640 913958933 572016595 240548090 520689519 84697186 522220435 826417382 265968076 985449588 56182308...

output:

162352243146

result:

ok single line: '162352243146'

Test #7:

score: 40
Accepted
time: 1ms
memory: 5732kb

input:

1999
509123260 509123260 509123260 509123260 509123260 509123260 509123260 509123260 509123260 509123260 509123260 509123260 509123260 509123260 509123260 509123260 509123260 509123260 509123260 509123260 509123260 509123260 509123260 509123260 509123260 509123260 509123260 509123260 509123260 50912...

output:

999

result:

ok single line: '999'

Test #8:

score: 40
Accepted
time: 1ms
memory: 3620kb

input:

2000
505570238 505570238 505570238 505570238 505570238 505570238 505570238 505570238 505570238 505570238 505570238 505570238 505570238 505570238 505570238 505570238 505570238 505570238 505570238 505570238 505570238 505570238 505570238 505570238 505570238 505570238 505570238 505570238 505570238 50557...

output:

1000

result:

ok single line: '1000'

Test #9:

score: 40
Accepted
time: 1ms
memory: 5700kb

input:

1999
1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 100000000...

output:

500000000000

result:

ok single line: '500000000000'

Test #10:

score: 40
Accepted
time: 1ms
memory: 3688kb

input:

2000
928502282 928502281 928502280 928502279 928502278 928502277 928502276 928502275 928502274 928502273 928502272 928502271 928502270 928502269 928502268 928502267 928502266 928502265 928502264 928502263 928502262 928502261 928502260 928502259 928502258 928502257 928502256 928502255 928502254 92850...

output:

0

result:

ok single line: '0'

Test #11:

score: 40
Accepted
time: 1ms
memory: 5712kb

input:

2000
381796934 381796935 381796936 381796937 381796938 381796939 381796940 381796941 381796942 381796943 381796944 381796945 381796946 381796947 381796948 381796949 381796950 381796951 381796952 381796953 381796954 381796955 381796956 381796957 381796958 381796959 381796960 381796961 381796962 38179...

output:

0

result:

ok single line: '0'

Test #12:

score: 40
Accepted
time: 1ms
memory: 5624kb

input:

2000
34723367 34723368 34723369 34723370 34723371 34723372 34723373 34723374 34723375 34723376 34723377 34723378 34723379 34723380 34723381 34723382 34723381 34723380 34723379 34723378 34723377 34723376 34723375 34723374 34723373 34723372 34723371 34723370 34723369 34723368 34723367 34723366 3472336...

output:

0

result:

ok single line: '0'

Test #13:

score: 40
Accepted
time: 1ms
memory: 5632kb

input:

1999
999 998 997 996 995 994 993 992 991 990 989 988 987 986 985 984 983 982 981 980 979 978 977 976 975 974 973 972 971 970 969 968 967 966 965 964 963 962 961 960 959 958 957 956 955 954 953 952 951 950 949 948 947 946 945 944 943 942 941 940 939 938 937 936 935 934 933 932 931 930 929 928 927 926...

output:

1996

result:

ok single line: '1996'

Test #14:

score: 40
Accepted
time: 1ms
memory: 3556kb

input:

2000
41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 1000000000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60...

output:

3914

result:

ok single line: '3914'

Test #15:

score: 40
Accepted
time: 1ms
memory: 5712kb

input:

2000
1982 1981 1980 1979 1978 1977 1976 1975 1974 1973 1972 1971 1970 1969 1968 1967 1966 1965 1964 1963 1962 1961 1960 1959 1958 1957 1956 1955 1954 1953 1952 1951 1950 1949 1948 1947 1946 1945 1944 1943 1942 1941 1940 1939 1938 1937 1936 1935 1934 1933 1932 1931 1930 1929 1928 1927 1926 1925 1924 ...

output:

3962

result:

ok single line: '3962'

Test #16:

score: 40
Accepted
time: 0ms
memory: 5712kb

input:

2000
804179299 802936882 801545076 801442395 800688418 799549773 799451478 799363638 799132692 798051173 797940858 796739560 795242488 795091546 793759389 793655151 793313193 791204832 790719724 789424622 787782518 787557905 787148533 785757675 784571540 784341113 783856911 783830458 782289616 78226...

output:

571700077

result:

ok single line: '571700077'

Test #17:

score: 40
Accepted
time: 1ms
memory: 5628kb

input:

2000
972683350 949509658 939286132 933941234 916106799 915943015 904121316 868808873 847426343 711839041 573396030 559683504 509245297 507250457 460878383 449622417 443002082 398887960 353053505 294812903 272272817 249712606 213920274 212319347 201472013 169958837 126368791 116502931 100321229 92214...

output:

907398495

result:

ok single line: '907398495'

Test #18:

score: 40
Accepted
time: 1ms
memory: 3668kb

input:

2000
991473554 990850819 990340866 990026294 989985490 989307567 989232726 988913408 987038594 986129281 985858784 985551269 982508743 982156047 981607532 981058073 980895160 980280387 980229744 980040087 980013450 978916786 978313390 978278262 978057888 976855610 976689061 976441132 976370371 97570...

output:

967279870

result:

ok single line: '967279870'

Test #19:

score: 40
Accepted
time: 1ms
memory: 5692kb

input:

2000
998756973 997467985 996478975 996006642 995823892 994570659 993304165 991753891 989410653 985567771 985364929 984934816 984490335 983402886 982902511 982877468 981553686 979623227 978800471 972896261 971835596 969732176 969272190 966526388 965773546 962746258 956394746 956230664 953116047 95103...

output:

998407790

result:

ok single line: '998407790'

Test #20:

score: 40
Accepted
time: 1ms
memory: 3596kb

input:

2000
928181167 920153828 920136877 864457750 852215106 837332406 821527799 821527799 821527799 821527799 821527799 821527799 821527799 821527799 821527799 821527799 821527799 821527799 821527799 821527799 821527799 821527799 821527799 821527799 821527799 821527799 821527799 821527799 821527799 82152...

output:

106653424

result:

ok single line: '106653424'

Test #21:

score: 40
Accepted
time: 1ms
memory: 3740kb

input:

2000
947527030 947093623 945159818 944837191 944688849 944316886 943317320 943273360 943195778 942656630 941408481 940032963 939894924 939652227 938886199 938012888 936704143 936214846 935842031 935833299 934869524 932724867 931414350 931104377 930915533 930597261 930578459 930502580 929838708 92922...

output:

903551804

result:

ok single line: '903551804'

Test #22:

score: 40
Accepted
time: 1ms
memory: 5708kb

input:

2000
910241030 909123835 904705607 903836388 901268933 900887668 900737840 900561887 899855497 897320085 896440490 894846388 893535191 892739153 887025418 886169036 885791899 884414824 883280175 882560297 880493376 878399187 872307436 872243563 871708917 871228072 870801476 869874660 868639474 86543...

output:

177674781

result:

ok single line: '177674781'

Test #23:

score: 40
Accepted
time: 1ms
memory: 5772kb

input:

2000
958322425 957022113 955880250 954780601 954115026 951523391 951267126 951267126 948038619 939956108 939956108 934612398 933140918 933140918 930398377 928471987 928471987 926584674 925169982 922498555 922377310 919721088 917498495 905989978 905726808 904911127 904911127 904161840 894804833 88928...

output:

643270319

result:

ok single line: '643270319'

Test #24:

score: 40
Accepted
time: 1ms
memory: 5688kb

input:

2000
727652356 726647068 726288090 723706031 722980876 722538402 721776619 720802123 720757279 720283330 720258236 720071273 720055816 719795850 717774595 717774595 716801455 716046684 715324060 715323480 715226475 715207239 715102784 714864333 714639354 712222568 712076104 711099485 710625540 70889...

output:

656755752

result:

ok single line: '656755752'

Subtask #2:

score: 60
Accepted

Dependency #1:

100%
Accepted

Test #25:

score: 60
Accepted
time: 1ms
memory: 5692kb

input:

2001
884953730 4015595 726912949 519508315 708508942 12364496 286349693 699837926 934065390 697606387 875580140 68179052 344720591 262737896 850449301 654976282 349069605 373553656 301229585 77981428 547973387 673952468 873443888 55125979 354667843 609351730 726214110 757032594 812674601 666110268 3...

output:

161549557235

result:

ok single line: '161549557235'

Test #26:

score: 60
Accepted
time: 51ms
memory: 8940kb

input:

199999
551691302 800582045 14063803 52897269 153641504 567834643 453508034 853479486 949940012 931639209 527379143 577323364 454806733 548126558 164112328 646222819 175848606 757955322 998100803 719046844 365712755 776737361 360112857 351715858 109448787 133312326 722808924 29909235 713844652 770497...

output:

16681993428147

result:

ok single line: '16681993428147'

Test #27:

score: 60
Accepted
time: 48ms
memory: 9236kb

input:

200000
286992568 522764708 858066681 411939222 278314510 736125071 314440633 992793856 734353326 240422976 225920052 352786511 602541355 81404074 530105212 818763008 810855705 616679962 248031884 578540108 84027762 130118948 183098801 699629343 715233271 515270693 777024368 862984169 320984713 85112...

output:

16618723651088

result:

ok single line: '16618723651088'

Test #28:

score: 60
Accepted
time: 52ms
memory: 10320kb

input:

199999
560229147 560229147 560229147 560229147 560229147 560229147 560229147 560229147 560229147 560229147 560229147 560229147 560229147 560229147 560229147 560229147 560229147 560229147 560229147 560229147 560229147 560229147 560229147 560229147 560229147 560229147 560229147 560229147 560229147 560...

output:

99999

result:

ok single line: '99999'

Test #29:

score: 60
Accepted
time: 52ms
memory: 9632kb

input:

200000
958635898 958635898 958635898 958635898 958635898 958635898 958635898 958635898 958635898 958635898 958635898 958635898 958635898 958635898 958635898 958635898 958635898 958635898 958635898 958635898 958635898 958635898 958635898 958635898 958635898 958635898 958635898 958635898 958635898 958...

output:

100000

result:

ok single line: '100000'

Test #30:

score: 60
Accepted
time: 35ms
memory: 8296kb

input:

199999
1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000...

output:

50000000000000

result:

ok single line: '50000000000000'

Test #31:

score: 60
Accepted
time: 52ms
memory: 8192kb

input:

200000
668543520 668543519 668543518 668543517 668543516 668543515 668543514 668543513 668543512 668543511 668543510 668543509 668543508 668543507 668543506 668543505 668543504 668543503 668543502 668543501 668543500 668543499 668543498 668543497 668543496 668543495 668543494 668543493 668543492 668...

output:

0

result:

ok single line: '0'

Test #32:

score: 60
Accepted
time: 52ms
memory: 8188kb

input:

200000
820666346 820666347 820666348 820666349 820666350 820666351 820666352 820666353 820666354 820666355 820666356 820666357 820666358 820666359 820666360 820666361 820666362 820666363 820666364 820666365 820666366 820666367 820666368 820666369 820666370 820666371 820666372 820666373 820666374 820...

output:

0

result:

ok single line: '0'

Test #33:

score: 60
Accepted
time: 52ms
memory: 9904kb

input:

200000
417382559 417382560 417382561 417382562 417382563 417382564 417382565 417382566 417382567 417382568 417382569 417382570 417382571 417382572 417382573 417382574 417382575 417382576 417382577 417382578 417382579 417382580 417382581 417382582 417382583 417382584 417382585 417382586 417382587 417...

output:

0

result:

ok single line: '0'

Test #34:

score: 60
Accepted
time: 48ms
memory: 9232kb

input:

200000
417941691 417941692 417941693 417941694 417941695 417941696 417941697 417941698 417941699 417941700 417941701 417941702 417941703 417941704 417941705 417941706 417941707 417941708 417941709 417941710 417941711 417941712 417941713 417941714 417941715 417941716 417941717 417941718 417941719 417...

output:

0

result:

ok single line: '0'

Test #35:

score: 60
Accepted
time: 30ms
memory: 9324kb

input:

199999
99999 99998 99997 99996 99995 99994 99993 99992 99991 99990 99989 99988 99987 99986 99985 99984 99983 99982 99981 99980 99979 99978 99977 99976 99975 99974 99973 99972 99971 99970 99969 99968 99967 99966 99965 99964 99963 99962 99961 99960 99959 99958 99957 99956 99955 99954 99953 99952 99951...

output:

199996

result:

ok single line: '199996'

Test #36:

score: 60
Accepted
time: 33ms
memory: 9500kb

input:

200000
199541 199540 199539 199538 199537 199536 199535 199534 199533 199532 199531 199530 199529 199528 199527 199526 199525 199524 199523 199522 199521 199520 199519 199518 199517 199516 199515 199514 199513 199512 199511 199510 199509 199508 199507 199506 199505 199504 199503 199502 199501 199500...

output:

399080

result:

ok single line: '399080'

Test #37:

score: 60
Accepted
time: 36ms
memory: 9184kb

input:

200000
876 875 874 873 872 871 870 869 868 867 866 865 864 863 862 861 860 859 858 857 856 855 854 853 852 851 850 849 848 847 846 845 844 843 842 841 840 839 838 837 836 835 834 833 832 831 830 829 828 827 826 825 824 823 822 821 820 819 818 817 816 815 814 813 812 811 810 809 808 807 806 805 804 8...

output:

398244

result:

ok single line: '398244'

Test #38:

score: 60
Accepted
time: 50ms
memory: 9852kb

input:

200000
899969419 899967603 899966884 899965344 899947919 899947783 899945212 899937178 899935036 899928049 899927067 899925235 899910949 899904018 899896329 899891800 899889806 899853074 899820360 899814852 899809612 899796869 899794201 899791202 899787728 899784743 899781838 899774151 899767652 899...

output:

880421727

result:

ok single line: '880421727'

Test #39:

score: 60
Accepted
time: 51ms
memory: 8808kb

input:

200000
878098349 877959270 877729790 877666192 877569263 877273057 877179590 876901601 876683944 876425832 876228295 876223249 875335562 875307288 875215318 875212253 875039374 875037298 874980112 874951440 874799321 873982211 873780791 873230105 873197455 872825086 872803589 872691749 872348863 871...

output:

19845565

result:

ok single line: '19845565'

Test #40:

score: 60
Accepted
time: 52ms
memory: 8300kb

input:

200000
549622625 549622032 549621016 549620854 549620423 549619460 549619288 549618843 549616400 549615680 549611810 549606120 549604866 549604488 549602755 549601287 549600505 549599359 549598645 549598187 549597184 549596315 549596003 549594310 549593133 549592369 549590976 549589134 549581965 549...

output:

284515150

result:

ok single line: '284515150'

Test #41:

score: 60
Accepted
time: 49ms
memory: 9544kb

input:

200000
999999065 999980391 999979166 999977665 999969829 999969536 999965858 999962502 999961316 999957340 999954019 999949475 999931864 999924258 999920419 999917865 999913614 999912088 999904996 999891275 999885851 999884016 999880461 999875424 999872370 999857825 999854088 999847021 999846209 999...

output:

999429663

result:

ok single line: '999429663'

Test #42:

score: 60
Accepted
time: 40ms
memory: 8936kb

input:

200000
795046835 773363681 766074305 758874221 755153371 748725349 740929913 721294168 715698027 709866169 677945479 674012535 662841949 631377178 624794295 618345930 616440553 611602868 602234284 582021346 569822837 556974524 555646252 548280135 541343932 540183486 535231065 523372845 521857096 515...

output:

729979825

result:

ok single line: '729979825'

Test #43:

score: 60
Accepted
time: 45ms
memory: 10212kb

input:

200000
732587327 732582111 732573603 732557744 732550540 732549869 732549650 732549593 732527063 732523230 732511034 732508331 732506597 732496546 732494877 732492463 732484388 732481682 732463839 732445298 732443230 732419536 732417838 732410664 732409402 732395965 732395659 732392260 732386954 732...

output:

53060377

result:

ok single line: '53060377'

Test #44:

score: 60
Accepted
time: 51ms
memory: 10056kb

input:

200000
338705370 338692467 338689247 338674764 338673811 338673365 338672476 338671573 338668889 338666476 338662412 338657891 338650887 338650519 338647210 338645823 338644154 338640844 338639692 338639300 338638675 338636540 338635296 338633771 338633194 338632570 338624596 338622871 338618638 338...

output:

325889318

result:

ok single line: '325889318'

Test #45:

score: 60
Accepted
time: 52ms
memory: 10236kb

input:

200000
771550181 771540168 771537648 771533863 771526271 771516385 771516174 771516102 771512276 771508265 771505325 771504021 771502092 771487625 771486018 771481841 771481182 771475521 771468081 771465140 771464767 771463521 771463027 771457144 771447235 771447016 771446238 771443437 771436679 771...

output:

688550750

result:

ok single line: '688550750'

Test #46:

score: 60
Accepted
time: 48ms
memory: 9740kb

input:

200000
328471591 328381022 328355852 328351298 328276338 328256404 328206353 328143839 328096939 328088148 328048920 327953531 327936306 327936306 327877890 327867528 327834497 327804376 327789034 327786481 327782876 327714403 327694128 327671457 327657188 327655242 327617376 327604383 327601095 327...

output:

219146466

result:

ok single line: '219146466'

Test #47:

score: 60
Accepted
time: 48ms
memory: 8964kb

input:

200000
419061808 419061458 419060392 419060360 419059578 419058960 419058680 419058603 419058315 419058260 419057578 419057414 419057137 419057000 419056736 419056469 419056343 419056066 419055955 419055836 419055789 419054827 419054553 419053907 419052866 419052735 419052560 419052278 419051989 419...

output:

67809208

result:

ok single line: '67809208'

Test #48:

score: 60
Accepted
time: 48ms
memory: 8296kb

input:

200000
762901800 723418958 698131043 519764034 517846873 515546637 448612597 385298341 365820776 271511381 244477799 146704820 116644466 110340674 98912945 98912945 98912945 98912945 98912945 98912945 98912945 98912945 98912945 98912945 98912945 98912945 98912945 98912945 98912945 98912945 98912945 ...

output:

663988873

result:

ok single line: '663988873'

Extra Test:

score: 0
Extra Test Passed