CT32996

Neel's Shelf Position Ledger

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Morning light hits the lily shoals of Padmore as Neel unrolls the day's manifest of crates. The tally will decide the next shipment. 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 <= 7155; 0 <= a[i],x <= 1000000.

Example 1:

Input: 1034 570378 900 1731 4378 4459 5360 6311 7440 8252 8899 8985 9530 10680 11187 11211 12089 12225 12298 12637 14915 15266 15443 16345 16362 18188 18656 20255 21361 23427 23461 23748 27172 30214 30284 31995 33018 33370 33398 33896 34280 34592 34740 37149 37453 37759 38833 38887 40680 40854 41618 42374 42794 44108 44124 45090 45819 46355 48884 49207 50527 51484 54344 54531 56951 58080 58799 59100 59649 59948 59991 63637 64691 65685 65765 68676 69033 69651 69703 69970 70226 71137 73615 74457 74537 74865 75135 76747 78085 78466 78918 79199 79454 83172 83900 84633 85141 86049 87230 87390 89892 92452 95289 96692 97484 98105 99963 101141 101475 102361 104228 105324 106037 106684 108036 109793 110400 110423 111338 112084 112110 112477 114537 114967 116456 116829 118893 122024 122643 124364 124405 12…
Output: 594

Example 2:

Input: 6595 306151 96 443 482 482 611 736 926 1058 1350 1609 1618 1726 1727 1943 2104 2119 2613 2635 2638 2688 2728 2768 3029 3037 3253 3307 3374 3858 3930 3969 4016 4028 4365 4689 4884 4963 5232 5346 5368 5516 5587 5989 6024 6182 6588 6612 7169 7268 7375 7440 7704 7982 8250 8294 8587 8628 8703 8752 9059 9071 9343 9385 9462 9613 9616 9657 9695 9715 9751 9761 9778 9865 9954 10485 10579 10978 11335 11474 11498 11560 11575 11744 11961 12325 12365 12538 12611 12671 12741 12778 12860 12922 12963 12972 13200 13235 13388 13640 13782 13882 13983 14361 14544 14546 14589 14659 14783 14820 14857 15046 15062 15179 15224 15261 15494 15599 15772 15904 16253 16563 16576 16668 16827 17081 17159 17491 17498 17505 17529 17877 17887 17982 17988 18174 18307 18466 18566 18830 18893 19069 19689 19695 19754 20026 20097…
Output: -1

Example 3:

Input: 4697 609936 78 83 459 984 1328 2032 2088 2156 2168 2254 2357 2495 2561 2620 2874 2900 2909 2935 3360 4390 4602 4950 5087 5411 5414 5487 5679 5719 6101 6201 6528 6678 7052 7867 8074 8540 8875 9191 9264 9370 9426 9466 9922 10062 10270 10441 10491 10664 10796 10885 11009 11036 11089 11382 11663 11669 11859 12094 12311 12435 12762 12846 12848 12896 13002 13006 13283 13698 14016 14075 14186 14616 14675 14981 15036 15498 15744 15882 16010 16061 16152 16162 16238 16332 16442 16575 16619 16672 16852 17115 17175 17373 17679 18159 18172 18383 18434 18990 19181 19603 19616 19620 20280 20349 20393 20431 20594 20731 20786 21178 21298 21365 21460 21516 21617 21644 22393 22445 22702 22778 22993 23075 23345 23562 23600 23679 23729 23827 24014 24089 24355 25513 25595 25676 26030 26230 26317 26323 26477 264…
Output: 2918

Constraints:

1 <= n <= 7155; 0 <= a[i],x <= 1000000.

Loading...
Test Cases:No test cases
No test cases available.