CT32591

Aria's weights Shelf Position

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Caravans arrive at the cork grove of Barkhaven with crates of weights, and Aria the tallyman must account for every last one. 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 <= 5178; 0 <= a[i],x <= 1000000.

Example 1:

Input: 3525 244132 4 89 133 469 517 878 1246 1830 2073 2283 2333 2452 2562 3354 3632 4134 4329 4500 4811 5070 5320 5796 6151 6345 6620 7266 8388 8588 8673 8765 8856 9233 9430 9899 10157 10334 10660 11865 11955 11958 12104 12516 12781 12824 12855 12869 12955 13006 13025 13030 13591 13913 13961 14123 15158 15266 15356 15530 15585 15691 16243 16459 16883 17396 17410 17458 17953 18585 18689 19061 19942 20173 20530 20593 20953 21066 21461 22084 22229 22237 22478 22564 22656 22689 23001 23105 23495 23657 24275 24282 24346 24596 24601 24825 25218 25383 25416 26081 26083 26202 26294 26572 26733 26800 26820 26886 27174 27353 27396 27563 27766 28748 29356 29497 29546 30309 30715 31354 32101 32252 32317 32408 32524 32901 33088 33142 33862 33904 33992 34445 34586 34754 35350 35474 36057 36153 37426 37500 375…
Output: 859

Example 2:

Input: 1772 472324 481 538 2042 2157 2590 2592 3990 5804 5838 5999 6229 6242 6262 7970 8028 9021 9031 9057 9123 9788 10150 10308 10422 10488 10636 12024 13002 13004 13267 13343 13853 13923 15115 15866 16013 16042 16347 16366 16639 16699 16782 16833 17810 17904 19268 19378 19380 21380 21831 22326 22717 22821 23765 23983 24206 24402 24492 25198 25553 25783 25898 26144 26494 26788 27155 27909 29786 31124 31550 31652 31824 31958 32001 32462 32989 34930 34977 35571 35849 35983 36104 36592 36864 37150 37712 37913 37964 38929 39971 41127 41511 42607 42802 42831 43695 43748 43876 44126 44229 45650 45812 46038 46802 46828 47468 49720 50019 50357 50881 51648 52309 52523 52536 53732 55459 55556 55843 55881 56168 56476 56825 56979 58840 59181 59321 60498 60556 60810 61138 61141 61156 61441 61549 61617 63664 …
Output: -1

Example 3:

Input: 1937 913426 149 555 884 956 1962 2297 2686 2758 5077 5285 5822 5994 6249 6486 6527 6636 6949 7499 7870 8467 8826 9487 10093 10859 10866 11156 11307 11695 11726 12442 12475 13784 13790 14326 14483 15375 16068 16267 16628 17634 18467 18634 20305 23469 23563 23931 24179 24460 26327 26927 26937 26942 27076 27575 27898 28532 28738 28796 29935 30139 30511 30777 31017 31241 31658 32178 32479 32910 32915 33015 33693 34702 34818 35236 36857 38278 38371 39461 39744 40251 41278 41778 42323 42633 43109 43700 44189 44286 45064 45502 46307 47168 50221 50674 51563 51968 52364 53664 54015 54070 54499 55864 55889 56795 57272 57728 57736 57823 58277 58599 58778 58930 59117 59567 61096 61845 62346 62349 62779 62981 63049 63229 63252 63386 63940 65470 65650 66366 67592 67864 69862 69947 70063 70941 71327 7173…
Output: -1

Constraints:

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

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