Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.006 s | 1 KBi |
#2 |
Correcto
|
0.007 s | 0 KBi |
#3 |
Correcto
|
0.001 s | 0 KBi |
#4 |
Correcto
|
0.006 s | 1 KBi |
#5 |
Correcto
|
0.002 s | 0 KBi |
#6 |
Correcto
|
0.002 s | 0 KBi |
#7 |
Correcto
|
0.005 s | 1 KBi |
#8 |
Correcto
|
0.002 s | 0 KBi |
#9 |
Correcto
|
0.002 s | 0 KBi |
#10 |
Correcto
|
0.007 s | 2 KBi |
#11 |
Correcto
|
0.002 s | 0 KBi |
#12 |
Correcto
|
0.099 s | 2 KBi |
#13 |
Correcto
|
0.102 s | 2 KBi |
#14 |
Correcto
|
0.082 s | 1 KBi |
#15 |
Correcto
|
0.126 s | 2 KBi |
#16 |
Correcto
|
0.067 s | 1 KBi |
#17 |
Correcto
|
0.088 s | 1 KBi |
#include <bits/stdc++.h> using namespace std; void printArray(int arr[], int size) { for (int i = 0; i < size; i++) cout<<arr[i]<<endl; } int searchNextBiggest(int arr[], int arrSize, int x) { int low = 0; int high = arrSize - 1; while(low <= high) { int midPoint = (high + low) / 2; if(arr[midPoint] > x) { return midPoint; } else { low = midPoint + 1; } } return arrSize; } int main() { int n; cin>>n; int arr[n]; for(int i = 0; i < n; i++) { cin>>arr[i]; } int c; cin>>c; int res[c]; for(int j = 0; j < c; j++) { int x; cin>>x; int y = n; int low = 0; int high = n - 1; while(low <= high) { int midPoint = (high + low) / 2; if(arr[midPoint] > x) { y = midPoint; high = midPoint - 1; } else { low = midPoint + 1; } } res[j] = y; } printArray(res, c); return 0; }