QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#438480#8587. Photomatere100 ✓410ms11632kbC++141.2kb2024-06-10 18:53:062024-06-10 18:53:07

Judging History

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

  • [2024-06-10 18:53:07]
  • 评测
  • 测评结果:100
  • 用时:410ms
  • 内存:11632kb
  • [2024-06-10 18:53:06]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,s,a[1002][1002],l[1002],r[1002],ans=INT_MAX;
int main(){
    cin>>n>>s;
    for(ll i=1;i<=n;i++){
        for(ll j=1;j<=s;j++){
            cin>>a[i][j];
        }
        sort(a[i]+1,a[i]+s+1);
    }
    for(ll i=1;i<=s;i++){
        ll mid = a[1][i];
        vector<pair<ll,ll> > ls;
        for(ll j=2;j<=n;j++){
            l[j] = *lower_bound(a[j],a[j]+s+1,mid);
            if(l[j]==0) l[j] = INT_MAX;
            auto pr = upper_bound(a[j]+1,a[j]+s+1,mid);
            if(pr!=a[j]+1){
                pr--;
                r[j] = *pr;
            }
            else{
                r[j] = -INT_MAX;
            }
            // cout<<l[j]<<' '<<r[j]<<endl;
            ls.push_back({l[j],j});
        }
        sort(ls.begin(),ls.end());
        ans = min(ans,ls[ls.size()-1].first-mid);
        for(ll i=(int)ls.size()-1;i>0;i--){
            mid=min(mid,r[ls[i].second]);
            ans = min(ans,ls[i-1].first-mid);
            // cout<<ls[i].first<<' '<<mid<<' '<<ls[i].first-mid<<endl;
        }
        mid=min(mid,r[ls[0].second]);
        ans = min(ans,a[1][i]-mid);
        // cout<<ans<<endl;
    }
    cout<<ans<<endl;
}

詳細信息

Subtask #1:

score: 11
Accepted

Test #1:

score: 11
Accepted
time: 1ms
memory: 3836kb

input:

2 10
402 218 182 762 861 807 342 782 168 302
313 233 783 506 11 926 779 934 448 388

output:

1

result:

ok single line: '1'

Test #2:

score: 11
Accepted
time: 0ms
memory: 3784kb

input:

2 10
378 559 739 603 725 329 188 450 42 849
336 568 54 909 877 574 843 697 910 431

output:

6

result:

ok single line: '6'

Test #3:

score: 11
Accepted
time: 0ms
memory: 3532kb

input:

2 10
906 885 299 887 905 189 489 582 36 760
46 391 722 92 172 351 247 280 113 850

output:

10

result:

ok single line: '10'

Test #4:

score: 11
Accepted
time: 0ms
memory: 3544kb

input:

2 100
859221 708933 59310 895271 252441 821762 69139 108515 739532 461173 442706 371355 85775 316800 859125 615467 219511 90903 809338 227266 327436 126277 411797 428452 502091 244519 854059 78185 722085 755439 344983 666492 793726 361250 356712 880540 233454 643291 586785 343646 306499 190790 47353...

output:

13

result:

ok single line: '13'

Test #5:

score: 11
Accepted
time: 0ms
memory: 3788kb

input:

2 100
374912 584978 841974 377962 501580 829682 228927 247558 934218 860301 756374 386064 613680 708364 925308 594568 496745 83496 801125 854211 62483 67956 530299 371501 115458 452305 921114 854337 943419 482295 239250 209939 216250 194483 207401 445191 389356 288355 395094 963798 527413 606972 589...

output:

49

result:

ok single line: '49'

Test #6:

score: 11
Accepted
time: 0ms
memory: 3796kb

input:

2 1000
218861037 359256657 923610715 789299087 23683332 370864968 683327661 97820595 38491806 714105995 50058610 882968065 659946799 694839028 150403222 57238622 288632763 750532113 701948887 203147940 298604636 865495719 48003913 778791197 155678399 764534059 324919764 526866700 129461415 732362823...

output:

433

result:

ok single line: '433'

Test #7:

score: 11
Accepted
time: 1ms
memory: 3768kb

input:

2 1000
253743128 68295376 423996682 285556585 761072589 201979483 429991062 454728294 582455818 237497660 617479444 195997556 675450873 360055236 380574888 260233583 896349270 709996028 998565450 372673064 671884277 144580124 376328261 787133666 647869498 730599701 945587896 585790680 629026207 4532...

output:

392

result:

ok single line: '392'

Test #8:

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

input:

2 1000
399234638 27592422 906739262 885568125 453971491 144302096 24480895 248295633 270234212 764350665 805773844 705221663 535882219 113391768 963572093 964039521 9614075 385948940 654448346 935549912 839906229 611763253 357756530 302948230 866154660 555117352 607728944 707942322 618582834 7847778...

output:

1530

result:

ok single line: '1530'

Test #9:

score: 11
Accepted
time: 1ms
memory: 3796kb

input:

2 1000
46117187 133987156 572524038 682062813 400536196 175582263 73995782 877974052 549624020 415620547 607430340 737565256 417137939 621413871 430701431 967965485 834598516 75429672 617001198 641796457 152312575 24274640 519142922 292637640 834100240 975031226 401091137 285910982 245502678 6059316...

output:

66

result:

ok single line: '66'

Test #10:

score: 11
Accepted
time: 1ms
memory: 3564kb

input:

2 1000
187334004 177079545 329109864 428027405 946032346 532028369 915369154 472149390 62170960 193905435 737438511 831654859 754685198 944038790 957792091 578744885 555583057 478074211 347669556 437671456 282152411 960532777 221575535 946668357 893827953 210922481 203377665 943085631 283833948 8278...

output:

320

result:

ok single line: '320'

Test #11:

score: 11
Accepted
time: 0ms
memory: 3604kb

input:

2 3
2 1 8
5 4 7

output:

1

result:

ok single line: '1'

Subtask #2:

score: 22
Accepted

Test #12:

score: 22
Accepted
time: 4ms
memory: 5836kb

input:

100 100
586099 507648 564928 582479 131333 113635 212113 22622 935532 175855 551771 156287 722274 832977 388297 421668 665187 737499 990411 406111 493489 641988 550164 303402 378960 392357 486299 87008 463947 633918 909339 891009 666029 444527 237843 989298 14921 603071 356358 752954 857075 266649 3...

output:

24342

result:

ok single line: '24342'

Test #13:

score: 22
Accepted
time: 4ms
memory: 5852kb

input:

100 100
843113 905849 322626 952145 118983 649439 774580 61864 28385 429614 579416 568743 362855 42991 820662 292030 906651 474269 220972 822421 571925 591658 357420 173703 273090 784506 572604 277409 997089 297381 452788 15463 59013 958969 496259 353616 822678 393847 941867 397317 117391 899986 846...

output:

19179

result:

ok single line: '19179'

Test #14:

score: 22
Accepted
time: 0ms
memory: 4068kb

input:

100 100
458463 434442 89815 804957 805141 399693 137910 469083 87661 165658 95236 843790 603616 616271 352456 90931 643560 121835 280273 865325 2051 645395 155502 16962 84534 797070 623158 574429 734664 527882 291586 968971 912386 136085 648494 874430 524086 453284 444956 299597 99509 479951 742000 ...

output:

27320

result:

ok single line: '27320'

Test #15:

score: 22
Accepted
time: 4ms
memory: 6348kb

input:

100 100
748639 221362 470512 411814 711342 358044 584569 792837 606311 73442 550030 570347 995842 375283 551004 443912 344445 66911 381714 3057 239896 956639 833314 299612 246938 37451 370821 998 365962 643042 717492 790800 530230 701190 714351 502974 346800 804157 612986 935863 84555 952689 402523 ...

output:

24218

result:

ok single line: '24218'

Test #16:

score: 22
Accepted
time: 0ms
memory: 4320kb

input:

100 100
501344 450875 573517 482347 750228 249110 708226 725433 41744 653024 961785 938456 524876 627945 941699 942146 384723 639542 944837 368039 185861 116416 854585 273576 10005 535923 479533 724956 364171 95729 720706 793294 721730 85773 106286 754044 583915 77905 528123 839898 563785 423800 321...

output:

24132

result:

ok single line: '24132'

Test #17:

score: 22
Accepted
time: 0ms
memory: 5924kb

input:

100 100
970508860 601527793 155356597 36810437 89109711 685640770 316443889 876712782 694904068 567344061 800127318 368863953 473490369 387070468 939298827 805751300 963229328 538115582 108426014 595716895 267577375 77185623 372603389 268836447 651240129 936282109 605639165 423589510 88940780 559727...

output:

26196980

result:

ok single line: '26196980'

Test #18:

score: 22
Accepted
time: 2ms
memory: 5636kb

input:

100 100
746332284 992383587 807901704 816516464 420663050 621663271 152195023 597883568 296158466 29109643 191985966 148659373 598234753 229241583 592959186 95272872 800963044 645283992 868270571 349089799 244711504 484000557 112669361 932491476 883351083 343257659 453919451 502270525 701152672 2233...

output:

29576589

result:

ok single line: '29576589'

Test #19:

score: 22
Accepted
time: 2ms
memory: 4320kb

input:

100 100
801093512 788066804 267445712 967115847 576351698 728901734 403905622 574435948 596888007 357110397 549121557 143204176 315891420 86663405 730280901 727182263 708215084 458625453 216566019 283447788 907911669 805625975 514743502 849369659 871561753 522776396 901134858 94271860 542486174 5558...

output:

24946885

result:

ok single line: '24946885'

Test #20:

score: 22
Accepted
time: 4ms
memory: 6120kb

input:

100 100
893950099 16470102 85389628 901834871 676888997 715346782 692251347 563858541 638600906 651786899 470183163 787537890 306387450 66607710 180707443 672410647 613473630 441034873 382024561 13733601 678948310 640835188 942647326 199404332 429684084 973534771 217076501 427156339 282053119 465031...

output:

26003254

result:

ok single line: '26003254'

Test #21:

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

input:

100 100
806269215 256091801 770312747 710241765 754493571 440691841 153498264 618179576 528099773 963780191 524360513 418256259 775244478 27854177 496358835 54303194 354230352 571880359 108944785 969989769 190725774 857636037 259927312 593714639 357407079 604168261 106603386 41370910 77538590 516477...

output:

30522011

result:

ok single line: '30522011'

Test #22:

score: 22
Accepted
time: 1ms
memory: 3616kb

input:

3 3
3 1 4
2 7 18
9 8 10

output:

4

result:

ok single line: '4'

Subtask #3:

score: 9
Accepted

Dependency #2:

100%
Accepted

Test #23:

score: 9
Accepted
time: 17ms
memory: 7040kb

input:

250 250
7783036 6118405 6682594 645786 9936958 9581964 9620986 869073 185793 5569302 8248314 4115296 5821202 2753268 5633662 9548025 2892160 3134427 8288680 1047153 9987741 5580641 4816285 5337283 729793 1410180 6885509 5098636 2481415 3819683 1939983 8948624 3456207 3603715 5547243 4732084 5728186 ...

output:

136824

result:

ok single line: '136824'

Test #24:

score: 9
Accepted
time: 20ms
memory: 6196kb

input:

250 250
4238280 5557873 7823624 9655468 1088689 3025753 2271187 9138699 7569033 4005490 4681069 7293680 2926285 5918189 3297822 4753511 3118128 1799884 4266147 1376651 8887961 1228136 3108268 1711631 7833378 3455340 6551263 5756473 3628954 1471192 4534611 5956322 2537604 736895 8625046 6125303 50637...

output:

142368

result:

ok single line: '142368'

Test #25:

score: 9
Accepted
time: 17ms
memory: 5124kb

input:

250 250
90644 6215742 6200753 7128827 9564593 5883344 7631091 7787854 2546752 80771 4294976 6856719 3425071 576759 1219536 1590457 9164577 3868703 6929487 7867992 3304812 3691460 584926 7651214 9570330 5758591 9610770 2968593 5919212 1427523 7225459 6336171 8935762 4656849 2285823 3141049 8589428 61...

output:

134396

result:

ok single line: '134396'

Test #26:

score: 9
Accepted
time: 20ms
memory: 6136kb

input:

250 250
8354857 2819738 7707887 5927317 4667580 9492785 8100075 9341991 645389 6203688 4963393 4573398 6024904 1514869 682583 7278562 1625775 7518275 4002027 77695 6364440 7541744 1938954 5246423 7844077 1843472 1970586 8086790 9197611 4563432 1669840 8041244 5209316 2649203 8946875 989983 1683005 8...

output:

148137

result:

ok single line: '148137'

Test #27:

score: 9
Accepted
time: 17ms
memory: 6100kb

input:

250 250
6081600 6057815 6451120 8670571 1870548 7548732 6502954 1018762 6081609 5124482 3780258 8674731 2018439 8722437 5561969 79215 9907453 4762697 2344760 3225049 4940699 3432050 7253464 7308754 5526999 2770764 2691451 4726566 8842920 4164 1243145 3118469 8799630 7685228 1158196 4078466 4256392 4...

output:

131010

result:

ok single line: '131010'

Test #28:

score: 9
Accepted
time: 19ms
memory: 6480kb

input:

250 250
916902339 837141805 38524244 908055709 23131711 728194084 695893175 930809662 346716078 752084257 690359380 382215641 499072989 39163315 875094407 879597279 913591515 996023120 377081394 790007527 378134906 214413263 3717434 812959530 386096082 383314925 714718471 906918919 408944063 4320409...

output:

14396460

result:

ok single line: '14396460'

Test #29:

score: 9
Accepted
time: 22ms
memory: 5980kb

input:

250 250
601995482 654318363 227679291 943382281 672250604 564291218 43640884 685222385 970987032 425062996 840993811 942299053 481042694 840195529 83079277 537413792 810153683 90836975 419273095 60085764 190352 475670488 459396573 877678178 238389440 290515753 643040413 865515035 282998238 246424221...

output:

13410529

result:

ok single line: '13410529'

Test #30:

score: 9
Accepted
time: 23ms
memory: 5092kb

input:

250 250
79626554 122473751 600155833 405258176 403734565 126495210 846432263 792731577 363280791 683439642 237972351 235311912 145370341 502731473 222605480 123824569 118611688 357166174 860906700 790658172 935729790 903347377 563794298 849342052 81738504 591306723 760405766 502017227 527975147 3092...

output:

13249392

result:

ok single line: '13249392'

Test #31:

score: 9
Accepted
time: 23ms
memory: 6212kb

input:

250 250
81752860 42039029 249676984 890565043 262028906 867790700 791998755 965139211 163169029 779263894 768066636 659933618 847867499 736504172 932389237 851932214 522890174 622188334 158969282 892425126 201944644 742741984 117376698 160248857 409786344 807131592 156389066 714816807 679127478 3690...

output:

13572224

result:

ok single line: '13572224'

Test #32:

score: 9
Accepted
time: 22ms
memory: 5744kb

input:

250 250
440046013 403669291 791791947 277387761 638830266 548300640 637300700 528947525 669766795 734663806 206490312 757417916 571189030 724962441 231337832 320351372 788631401 195705612 203893308 577753266 467319699 87273362 701174116 355095916 927686089 763576878 273528103 88466109 322418834 3632...

output:

14043108

result:

ok single line: '14043108'

Subtask #4:

score: 33
Accepted

Dependency #3:

100%
Accepted

Test #33:

score: 33
Accepted
time: 86ms
memory: 9124kb

input:

500 500
10813022 13116429 96542558 22955420 32786838 26068563 98100117 70415129 72384176 54718632 44526117 23407951 90519683 31054835 26838345 35518806 54442189 5159067 69133151 37933065 77798062 71806734 12968297 36633991 50029865 12907582 37437325 32275124 72906150 83911711 32780950 91433653 74245...

output:

824149

result:

ok single line: '824149'

Test #34:

score: 33
Accepted
time: 89ms
memory: 8288kb

input:

500 500
67486142 84251004 96579877 58322132 35913636 98288206 55172032 47818350 4126271 61366579 80088885 7829185 28345150 70025279 70567431 23771906 80728339 11378922 65969852 81725452 15095670 27417745 91383643 33681629 23349731 13367539 46367474 13438487 97801751 66883508 47384594 93182336 408892...

output:

792655

result:

ok single line: '792655'

Test #35:

score: 33
Accepted
time: 81ms
memory: 7756kb

input:

500 500
46082271 82348341 12922243 36815106 19671061 20821726 51678124 52008638 85700913 2593560 89545741 10892985 35514915 79797972 5660929 80142941 67915345 66435479 21779861 89398508 61977875 15867132 51375373 44150007 60225077 96686127 24801119 94894568 53800824 47122802 10036150 45836921 840540...

output:

811751

result:

ok single line: '811751'

Test #36:

score: 33
Accepted
time: 84ms
memory: 7904kb

input:

500 500
38774987 40562700 86006613 36458334 77820691 19603913 9367874 51772008 61717993 15088418 54214133 68897655 80307365 54564476 74672680 24125987 84429187 32697792 51456440 83089352 10024228 29192411 38216488 2808835 8489739 53061694 7202591 85152057 83631905 45951838 39332581 4192528 74872370 ...

output:

817306

result:

ok single line: '817306'

Test #37:

score: 33
Accepted
time: 81ms
memory: 7572kb

input:

500 500
47443063 90585148 91876282 92393220 99187740 47535142 16536183 42936057 89668791 92191641 32244620 99764917 65541211 33759655 92657781 17972164 67952266 57712117 77737567 15117190 57230783 32556349 45207214 183726 46092516 9866189 65535609 36259268 55858908 89189127 48891657 11120292 1411839...

output:

791264

result:

ok single line: '791264'

Test #38:

score: 33
Accepted
time: 86ms
memory: 8420kb

input:

500 500
648391376 233938422 824469766 859385707 332068572 124153527 959651736 801065888 868304899 805835993 20680779 678159495 943924778 170295552 95930694 951475669 232142299 452512018 28976534 164134084 813849284 800177850 310748587 406557328 266424888 321830889 885780954 569877243 512977836 48556...

output:

8000170

result:

ok single line: '8000170'

Test #39:

score: 33
Accepted
time: 87ms
memory: 8340kb

input:

500 500
74425852 437964759 460751250 768095400 720575739 475224055 986421770 64965889 990057728 712155945 995753024 850233027 180358985 998539567 287212767 405370410 798913163 989997664 684139334 723092804 599567728 43941412 32945159 126588535 858638100 524717433 486425448 992940793 944389512 950928...

output:

8031849

result:

ok single line: '8031849'

Test #40:

score: 33
Accepted
time: 90ms
memory: 9080kb

input:

500 500
901518130 332440912 369837731 635334945 64592551 937502681 301209724 60492826 700335338 36521557 1764244 923533879 701911953 914903906 686096186 919884639 16456517 243972307 113152786 265337841 325252676 475803696 263021460 354091837 617136865 30766385 388865162 509358086 895919104 314184263...

output:

7655988

result:

ok single line: '7655988'

Test #41:

score: 33
Accepted
time: 88ms
memory: 9424kb

input:

500 500
349618473 933823265 466485319 109123045 222083678 488738860 925798541 742387739 557513963 70719725 211072151 814921513 953840909 175888407 674144443 29486191 240686803 511474772 729219170 950952576 755130529 147961535 818280075 615278497 830328751 277435754 307427911 331849293 454685832 1670...

output:

8317016

result:

ok single line: '8317016'

Test #42:

score: 33
Accepted
time: 101ms
memory: 7688kb

input:

500 500
153885664 122494794 451207807 779394292 193049119 274156785 155155516 815683331 561593603 524302065 473933641 524395931 81370046 341301583 956390242 439207770 441477942 672888032 682081591 74904304 624360071 60414930 963562221 465438115 793181055 529566755 652179101 165447117 915656993 99528...

output:

7331162

result:

ok single line: '7331162'

Subtask #5:

score: 25
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

100%
Accepted

Test #43:

score: 25
Accepted
time: 410ms
memory: 11508kb

input:

1000 1000
30688792 640786772 195209917 592417252 824564806 916486779 329733659 766400722 670688070 320845487 575077465 344312423 381296014 510719908 607162160 179317864 890890810 919632977 198734653 792125470 616901510 15199089 803893375 631082198 40163669 592660483 26520795 686363233 669725101 1610...

output:

4566018

result:

ok single line: '4566018'

Test #44:

score: 25
Accepted
time: 361ms
memory: 11460kb

input:

1000 1000
252322383 978429487 405311515 215463305 567703070 320011299 473659655 212432267 118312844 48868749 389756521 249768920 965058216 779957729 657672227 308896519 515121223 958358775 940287258 937975377 924642942 117795211 454315958 663706645 502336809 885840830 223648870 281851989 230072424 8...

output:

4624291

result:

ok single line: '4624291'

Test #45:

score: 25
Accepted
time: 368ms
memory: 11408kb

input:

1000 1000
975347014 612912995 508006925 744544122 419282945 547652157 372096914 344831788 563095529 491243479 403213353 828088008 689261815 543558816 857155644 33562495 111393577 301060777 723668603 522162277 376768767 165719592 545018968 315430131 154361856 479450105 731867276 593480067 837848371 5...

output:

4751353

result:

ok single line: '4751353'

Test #46:

score: 25
Accepted
time: 363ms
memory: 11632kb

input:

1000 1000
514013768 347911726 473441923 227635878 666563952 446309625 263584798 913890948 301435699 642112254 597352263 452858607 848327278 100312930 559207702 968591065 98116115 509994880 721092088 644925094 183445416 401742696 733536300 889210030 532480966 521445979 541880901 853237696 675293850 7...

output:

4745187

result:

ok single line: '4745187'

Test #47:

score: 25
Accepted
time: 353ms
memory: 11508kb

input:

1000 1000
772330311 764481347 383965821 609054623 869186843 817688201 510132503 196357531 775272964 749559104 518119883 305234570 62165659 325156418 196339742 732727104 619136492 754927101 420391748 266448230 667725305 945660658 870767785 468588022 73059381 594253367 715105900 746534336 646518281 27...

output:

4820600

result:

ok single line: '4820600'

Test #48:

score: 25
Accepted
time: 362ms
memory: 11476kb

input:

1000 1000
728363465 943418559 279812634 604729698 743416481 334452264 316189407 138152643 662190973 29644607 114333256 125987247 972431484 130959369 76721476 973028430 144396417 281365230 501472714 415628137 912913843 371826489 124234066 810248430 800756222 677298587 262398298 618439792 728564113 18...

output:

4687655

result:

ok single line: '4687655'

Test #49:

score: 25
Accepted
time: 350ms
memory: 11452kb

input:

1000 1000
745596171 564420757 63734347 796887920 431120434 230622265 432047175 206507219 136201484 434146988 618876019 469859412 318106001 136158291 251300752 368225590 236151786 261522667 769606612 998626126 742678263 743320579 963204965 185592197 427856586 470838143 940911841 651194970 417847082 2...

output:

4699720

result:

ok single line: '4699720'

Test #50:

score: 25
Accepted
time: 360ms
memory: 11428kb

input:

1000 1000
723695191 845746688 419947264 242543289 74334031 357617389 130890158 416554138 198736777 696886516 304100861 450117680 94123470 79734432 928448670 264233727 418871132 517977614 811591162 829751647 337058914 597880688 754765994 68408058 481564805 862507403 660898301 482336594 482023774 7455...

output:

4430287

result:

ok single line: '4430287'

Test #51:

score: 25
Accepted
time: 363ms
memory: 11472kb

input:

1000 1000
352928355 569137605 813978185 999779918 971213431 158985745 139534004 462712138 963462685 379010217 632813878 658528140 600516929 222706543 899794130 169913506 578151331 373376061 40628644 99214161 665758550 102801760 871509337 130131470 434676547 404862487 807073202 914519427 448404900 98...

output:

4741678

result:

ok single line: '4741678'

Test #52:

score: 25
Accepted
time: 368ms
memory: 11460kb

input:

1000 1000
603169584 734593506 100602917 953499694 536342954 49311656 752946009 45495009 319800008 475999178 720113182 834768486 837286376 565074625 755271725 520937504 744118463 92559225 166270675 247205157 288585683 292728787 723500403 635603647 282672898 687837988 524660738 507551983 462214650 185...

output:

4734561

result:

ok single line: '4734561'