CT23663

Pia's vials Shelf Position

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

It is audit day at the old quarter of Brasshaven. Pia spreads the vials records across the table and picks up a sharp pencil. 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 <= 546; 0 <= a[i],x <= 1000000.

Example 1:

Input: 95 871321 695 2852 11474 18116 19360 21487 39958 42655 44615 81262 86338 95306 118995 125948 150245 159733 211920 218767 237460 238395 239886 242915 275861 276487 279134 283642 287405 299916 301002 319371 321074 325416 327800 340652 357352 363816 379916 382890 409416 421942 424164 440451 442330 446579 518222 521121 545760 556592 560131 591440 603130 650268 660561 674641 686715 687748 689885 691534 700854 722778 735749 736506 739147 752014 774495 802772 812691 815353 822844 836510 837601 850651 852291 867542 871321 877059 884615 886253 902607 902994 911101 922165 954203 956738 958171 958425 959766 962703 963344 966989 975639 978748 980237 990817 991950
Output: 75

Example 2:

Input: 270 188249 1421 5041 7595 10327 13106 17409 18968 22761 27993 33198 35916 36687 37374 45013 47002 54664 57935 62406 65014 69206 76595 80535 82286 83939 85904 87545 88547 89397 92616 93964 100290 106483 108497 112318 115084 122655 123284 125213 125874 128192 131774 136664 139220 139421 140329 144037 144730 146009 146940 155537 155900 157920 158613 164136 168756 171052 171706 174703 174858 182569 188249 194422 201706 203593 210346 210354 212014 227705 229267 231025 232776 233336 236907 241465 243823 246254 257270 262736 266163 267669 274321 275050 293862 297294 298875 305648 305703 306300 309823 316386 316696 318866 319200 320972 325052 328424 331771 339921 342186 344576 354545 368797 371383 375055 380236 380586 384606 386393 388026 395569 398147 402610 406063 407666 420236 420902 421881 422…
Output: 61

Example 3:

Input: 378 623192 3663 4932 7164 8118 8321 9614 13145 13680 15650 17679 20776 21555 22813 27471 33792 38805 39211 44507 52412 52868 54271 62846 62916 64849 66246 67237 67755 72636 73690 76199 78070 82339 83707 90830 96347 97113 99974 101330 102077 107828 108724 116400 119027 122130 130775 132308 133554 138280 150047 150809 154721 155396 161142 161702 162839 167596 169672 169713 178499 187274 190069 203826 206916 207136 208212 213688 215305 217974 218755 223118 224734 225769 228690 229136 229924 230319 232143 242328 242955 250750 251460 252191 254416 256277 260678 268970 269676 273071 273724 274609 275592 277067 278015 281356 281393 283622 285013 286885 287860 292180 293537 295638 295967 297974 302908 306980 307723 311226 314174 323293 323435 326388 333265 334033 335790 342945 351713 357599 359663…
Output: -1

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Pia's vials Shelf Position - EASY Coding Problem | CodeTikki