Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.006 s | 3 KBi |
#2 |
Correcto
|
0.006 s | 2 KBi |
#3 |
Correcto
|
0.002 s | 0 KBi |
#4 |
Correcto
|
0.002 s | 1 KBi |
#5 |
Correcto
|
0.005 s | 3 KBi |
#6 |
Correcto
|
0.001 s | 0 KBi |
#7 |
Correcto
|
0.002 s | 8 KBi |
#8 |
Correcto
|
0.001 s | 0 KBi |
#9 |
Correcto
|
0.004 s | 4 KBi |
#10 |
Correcto
|
0.002 s | 0 KBi |
#11 |
Correcto
|
0.004 s | 3 KBi |
#12 |
Tiempo límite excedido
|
1.062 s | 1 KBi |
#13 |
Tiempo límite excedido
|
1.051 s | 1 KBi |
#14 |
Tiempo límite excedido
|
1.082 s | 2 KBi |
#15 |
Correcto
|
0.067 s | 1 KBi |
#16 |
Tiempo límite excedido
|
1.071 s | 1 KBi |
#17 |
Tiempo límite excedido
|
1.077 s | 2 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; break; } else { low = midPoint + 1; } } res[j] = y; if(y != n && low < high) { for(int k = y - 1; k >= low; k--) { if(arr[k] > x) res[j] = k; else break; } } } printArray(res, c); return 0; }