CT24834

The Shelf Position of the Peculiar weights

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

The harbor bell rings at the garden city of Petalbrook; Cressida weighs the day's weights manifests and starts the calculations. Task: The array is sorted in non-decreasing order. Print the 1-based index of the first occurrence of x, or -1 if x is absent. Input format: First line: n and x. Second line: n sorted integers. Output format: Print the 1-based index or -1. Constraints: 1 <= n <= 405; -1000000 <= a[i],x <= 1000000000.

Example 1:

Input: 276 194582485 -885664 1695533 5592974 7685573 12837391 24948156 27294449 27829498 28225101 28234014 38758227 42510719 47593186 48639036 52086182 55333711 67054870 73279576 81970948 84244624 95869592 101552979 102196226 102962984 107249017 107664388 107673381 109222597 112379901 121963705 122483858 123782975 134079892 134307484 134762606 136568927 140640078 148143348 148447292 148587574 152760345 155578049 161302475 165553303 170939813 172439161 178258066 179443320 185744974 185819585 186455067 194500482 196119096 197096216 205139263 207405951 214697528 214878761 215445840 217815996 219358640 224057787 228877583 234039617 235391485 243922027 262629824 277844945 279150173 285629405 289459294 298356315 300229238 301723523 306296581 308659633 308849788 312363579 315994900 318914426 321055785 321421389 325792848 326809334 327208576 329144275 330051649 331650656 331772347 332391649 333785575 336662456 339538758 344145047 349001560 349277211 350753069 354535983 358969456 367432381 368639992 371426258 372481628 374254243 378445526 387260641 388354836 390411491 391963091 395103272 403349343 414402919 414932303 416659980 417553804 419864529 425045271 426980582 440747820 447120830 462652551 470104778 473689547 480299040 481581148 483791125 488370878 492168041 492272545 501907883 504656116 506274044 506930190 517567960 521852141 522081566 522715000 525722929 527899472 530298438 531546651 531563418 533676502 536207658 537492709 537623683 540203451 541617443 543135354 547517455 547968962 548117365 550521441 550753107 550942828 556117876 565184023 570069962 570744656 572770772 573403426 582443751 584867487 594228030 595948849 596667088 598855756 600504597 605326627 607136712 612368172 619344810 620556914 623287717 627642155 635770981 636750340 638659357 640344343 643013209 646945355 647321328 647736113 658264714 659931728 660737841 663418631 672710889 672924016 681440664 690603106 693758811 694396546 697597512 697702323 700751433 701033655 711324142 713679129 715724419 715979027 718304483 718338772 719533370 723758189 725242589 725330446 725824585 727373814 733588298 743200157 744530257 744784718 753972889 756992601 764324249 772319054 778033529 780281076 781677645 786848540 788249435 795439903 796216959 798723616 798997363 800796354 808440364 810067844 810420848 810712898 814554015 814705407 815358803 818687313 823496081 828198169 829246229 830653052 831556352 835660323 836113195 839470812 839901866 841015616 848516501 857004982 870488600 871513936 880911492 886526737 888155621 891327785 891459543 893734671 900361235 904160507 904534799 911049247 912286120 919184002 930784543 939437955 951670448 955125205 968098711 971289126 974336753 979311260 979524174 981141077 984285133 985040019 987433171 992836618 996980709
Output: -1

Example 2:

Input: 61 242443813 8191780 11262931 22579491 30489237 35393510 40417773 63853383 80518653 111049333 116481275 145491892 151280321 155280760 165383997 173387832 179297184 196535082 205659189 209085941 242443813 260766709 265888663 276280796 294844752 304256972 350732067 377610720 395440586 425484206 430817300 453718707 460718295 515998313 526759082 549401372 569625547 572236890 582917062 632649432 633723102 691945058 694022473 702127736 707234875 720006292 731597373 736948953 762328227 763636050 787467341 797789871 830075116 841534367 849317465 860304339 863804985 931489572 940177303 951381441 956364637 958591522
Output: 20

Example 3:

Input: 50 379680369 154474 1623491 8952319 39530027 73347682 74055255 122903881 127367559 176283491 192924932 221247908 252810012 277330615 293177058 304927388 312622296 374332677 384378341 413383675 423756976 428658849 429780687 434162809 479989566 500663796 507600467 518297645 527997140 533656659 536317170 547016262 555068379 563640696 568831580 582335951 609141255 624166392 664521145 668048255 678850924 730107021 776530849 813332058 847073024 876156656 907688327 918906770 963143346 972407290 995860063
Output: -1

Constraints:

1 <= n <= 405; -1000000 <= a[i],x <= 1000000000.

Loading...
Test Cases:No test cases
No test cases available.
The Shelf Position of the Peculiar weights - EASY Coding Problem | CodeTikki