CT41527

Odin's Ledger of panels

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The customs officer Odin has been asked to prove the quality of the harvest. On the desk lies a long table of panels readings. Task: Print the number of index pairs (i,j), i<j, with a[i]+a[j] <= k. Input format: First line: n and k. Second line: n integers. Output format: Print the pair count (fits 64-bit). Constraints: 2 <= n <= 2968; 1 <= a[i],k <= 1000000000.

Example 1:

Input: 1816 1502482412 604050533 6551480 62073668 396836537 413023435 899350078 699784982 363229447 54196485 791153054 262992804 996792326 161459442 208037894 888033440 842576543 951078420 231729913 994833383 353887770 966481763 949749739 67478698 57789714 180142654 869095952 484952274 370240601 443868882 611125502 285738608 946066181 685285330 660991703 207574251 127737357 199954551 71684598 546028269 32240411 715318396 892414284 326366732 232593102 704885308 646481640 775768959 182637859 417029596 917548837 460882598 992683063 428661498 37527283 880552741 122487603 940576301 137441168 158028999 476734784 122344909 329628950 384303784 950898341 629490183 433788366 261569979 177085820 903604382 771556933 607350878 309782815 81660579 759982907 651642636 954420731 574916611 534020832 559277953 1802…
Output: 1435004

Example 2:

Input: 2043 1678782858 648403427 300128950 641916718 893244087 998783651 735909739 143138865 60488077 727348279 938390928 944258055 709770485 852948368 396266834 901570838 251468975 314943425 718701725 321363200 376382306 329962570 375537829 751781184 649585645 411104617 283004246 959152336 568644549 412606839 522604639 327446024 779560699 153026872 189143030 637727253 534604208 130625206 910131983 924312467 8603112 994861648 698037951 115490820 678998172 151982740 156216235 273496635 387216930 395774778 974759971 98144232 578795215 827327276 695912637 772145544 66963452 191539757 551143346 843515980 820829006 116346554 52901757 925250184 713625548 940977777 826145187 851254713 636124442 27701917 850736118 446626340 229581084 970524791 688104802 183834490 725154015 137198154 729774937 442427015 9…
Output: 1970711

Example 3:

Input: 790 1655738491 593497711 553116067 365564076 991283041 635685453 662630629 57017617 963224135 939650241 698910946 476976126 736292423 293721033 606401061 191526158 191730749 230766513 108203663 648668356 225712072 811839320 922723817 265727178 998811353 457757684 725726950 926071497 109289097 115894515 900760469 146219836 303597651 916113129 464391269 34389480 541456377 952524840 888687441 982482348 781400294 826795376 91847642 898000848 303006308 417251503 348690782 922932207 844447640 949505605 372219541 505033024 554891286 650821375 731505044 370193120 60112425 62620195 53524554 240719483 549173584 425353383 683426784 491149284 735505938 733401471 434343163 163037337 102875592 837138638 997115768 592294855 323307820 712801145 463985227 858578277 153091037 367819141 460469581 336911911 6…
Output: 287936

Constraints:

2 <= n <= 2968; 1 <= a[i],k <= 1000000000.

Loading...
Test Cases:No test cases
No test cases available.
Odin's Ledger of panels - MEDIUM Coding Problem | CodeTikki