CT33123

The Insertion Slot of the Radiant crates

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

The harbor bell rings at the floating docks of Skyharbor; Xara weighs the day's crates manifests and starts the calculations. Task: The array is sorted non-decreasing. Print the 1-based position where x would be inserted to keep the order (before equal values). Input format: First line: n and x. Second line: n sorted integers. Output format: Print the insertion position (1..n+1). Constraints: 1 <= n <= 10214; 0 <= a[i],x <= 1000.

Example 1:

Input: 1274 66 0 0 2 3 4 4 4 5 6 6 6 6 7 9 11 13 13 13 13 13 14 14 15 15 17 17 17 18 20 20 23 23 25 25 25 26 26 27 30 30 30 31 32 32 33 34 34 36 36 37 37 38 38 39 39 40 41 43 44 44 44 45 45 48 48 49 49 50 50 52 52 52 54 56 58 58 58 59 61 61 63 63 65 65 65 65 67 68 68 68 70 71 73 75 77 78 78 78 79 79 79 80 81 82 84 85 86 86 87 87 88 88 89 91 94 94 94 96 96 97 100 101 103 103 104 106 106 106 107 110 110 110 114 116 116 118 118 120 121 121 121 121 122 123 123 124 125 126 128 129 129 129 129 131 131 131 132 132 132 134 134 135 137 139 139 139 141 141 144 145 146 147 149 149 150 150 151 151 152 153 153 156 156 158 159 160 161 162 162 163 163 164 164 164 165 165 166 168 168 168 168 170 171 172 174 175 175 176 178 178 179 180 181 181 181 183 183 184 185 185 185 185 185 185 188 189 189 189 190 190 190 19…
Output: 87

Example 2:

Input: 3302 779 0 0 0 1 1 1 1 2 2 2 3 3 4 4 5 5 5 5 5 6 6 7 7 7 7 7 7 8 8 8 8 8 9 10 10 10 10 11 11 11 11 12 12 12 12 13 13 13 13 13 14 15 15 16 16 16 17 17 17 17 18 18 18 18 18 18 19 19 19 19 20 20 21 21 21 22 22 22 22 23 23 23 23 23 24 24 24 24 25 25 26 26 26 26 26 26 27 27 28 28 28 28 29 29 30 30 30 31 31 31 31 32 32 32 32 33 33 33 33 33 33 33 34 34 34 34 35 35 36 36 36 37 37 37 37 37 37 38 38 38 38 39 39 39 39 39 39 39 39 39 40 40 40 40 41 41 41 42 42 42 42 43 43 43 43 44 44 44 45 45 45 46 47 47 47 47 48 49 49 49 49 49 49 50 50 50 50 51 51 52 52 52 52 52 52 53 53 53 53 54 54 54 54 55 55 55 55 55 56 56 56 56 56 57 57 57 57 57 57 58 58 60 60 60 60 60 62 62 62 62 63 64 64 64 65 65 65 65 67 67 68 69 70 70 70 71 71 71 71 71 72 72 72 72 73 73 74 74 74 75 75 75 75 76 76 77 77 78 78 78 78 78 79 80 81…
Output: 2585

Example 3:

Input: 9505 502 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 5 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 9 9 9 9 9 9 10 10 10 10 10 10 10 10 10 10 10 10 11 11 11 11 11 11 11 12 12 12 12 12 12 12 13 13 13 13 13 13 13 13 13 14 14 14 14 14 14 14 14 14 14 14 15 15 15 15 15 15 16 16 16 16 16 16 16 16 16 16 16 16 17 17 17 17 17 17 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 20 20 20 20 20 20 20 20 20 20 20 20 21 21 21 21 21 21 21 22 22 22 22 22 22 23 23 23 23 23 23 23 23 24 24 24 24 24 24 24 24 25 25 25 25 25 25 25 25 25 25 26 26 26 26 26 26 27 27 27 27 27 27 27 27 27 28 28 28 28 28 28 28 29 29 29 29 29 29 29 30 30 30 30 30 30 30 30 30 30 30 30 31 31 31 31 31 31 31 31 31 31 31 32 32 32 …
Output: 4769

Constraints:

1 <= n <= 10214; 0 <= a[i],x <= 1000.

Loading...
Test Cases:No test cases
No test cases available.
The Insertion Slot of the Radiant crates - MEDIUM Coding Problem | CodeTikki