CT34592

Axel and the Misty shelves

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Caravans arrive at the foggy moor of Greyfen with crates of shelves, and Axel the store warden must account for every last one. Task: Print YES if two distinct elements sum to exactly k, otherwise NO. Input format: First line: n and k. Second line: n integers. Output format: Print YES or NO. Constraints: 2 <= n <= 5683; -1000000 <= a[i],k <= 1000000.

Example 1:

Input: 4769 -363995 -899484 -549055 -487708 -21574 -119252 -679750 -51388 208993 25255 740998 -165352 -586207 141146 369093 42 161970 -784298 -692696 515738 505983 506759 -142291 340716 -95818 414978 -773617 -607389 316406 752136 252821 -242346 597163 -223215 862272 369757 -729821 721315 -812110 745418 797161 345170 -622497 834036 672285 656066 893731 716501 970796 391312 -117516 -469064 908702 297301 -738079 -397399 127334 485763 119638 -945237 315204 -48806 -607433 289186 822813 -764189 15715 600425 -763138 644139 -961808 27631 33640 794153 -949215 848410 818022 -32198 816102 -525930 833022 64855 90742 132531 548467 -604837 227516 -451848 479957 -316079 -65520 95272 330409 904465 926672 330932 -133279 881809 251873 -595351 -922192 450641 76786 995090 248778 894600 939878 341388 -205094 647014 1…
Output: YES

Example 2:

Input: 2191 -974214 -169808 875050 -514543 944782 -433658 408546 157118 -905861 -669187 228272 -115067 833908 -157373 871507 -533112 191885 311466 570920 882613 -705190 992119 -749640 255170 384418 849178 -870528 -60379 -232417 533633 -733940 -948132 32673 451987 -875533 -302227 -245907 -685137 -904487 -185108 998540 -435609 8682 -371422 87365 309986 191392 505967 315374 761605 -929724 466298 -68354 -709908 -410888 -147270 -172315 758915 897376 632171 111768 592408 262435 -408505 722665 645584 -960808 254460 -842274 99801 -189445 547147 -156908 780424 -429069 403527 424817 917706 662065 649813 343498 203794 180421 -277487 -529671 -457483 940222 493172 -971138 -723450 -665249 763776 -743321 913829 -704839 -6806 940117 -252165 -145271 436434 255765 -315420 -601177 253654 -204380 -421058 753533 2744…
Output: NO

Example 3:

Input: 3947 -509632 -803205 287333 935917 -257775 -487535 -31167 -62934 -485016 -213858 -583402 -377840 -759961 695089 955510 -744057 966994 560506 800180 -9873 -797229 -992984 103850 -620655 484927 -243230 17844 -916967 -595281 -78814 889964 196288 -379095 -855560 459079 -641591 -653360 -475892 -332779 942583 505154 913511 89180 894110 -65414 682342 -96492 -884617 300172 692272 -293599 -974956 745029 690931 -479524 -554932 -548129 98012 -599121 73544 -538366 -408635 791659 338263 -373472 87675 994057 -672647 314441 -501938 487522 -842459 -867019 109839 452161 -283987 -546531 99661 568505 526908 -527444 -21293 -891343 483454 -779180 92861 713112 111635 -915926 -340706 99831 -336074 552909 883288 931612 -117090 153775 -891396 -767662 -1595 -570216 952528 139459 40829 702632 -751865 200614 -203049 …
Output: YES

Constraints:

2 <= n <= 5683; -1000000 <= a[i],k <= 1000000.

Loading...
Test Cases:No test cases
No test cases available.
Axel and the Misty shelves - MEDIUM Coding Problem | CodeTikki