Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.001 s | 0 KBi |
#2 |
Correcto
|
0.002 s | 0 KBi |
#3 |
Correcto
|
0.002 s | 0 KBi |
#4 |
Correcto
|
0.002 s | 0 KBi |
#5 |
Correcto
|
0.002 s | 0 KBi |
#6 |
Correcto
|
0.001 s | 0 KBi |
#7 |
Correcto
|
0.005 s | 61 KBi |
#8 |
Correcto
|
0.001 s | 0 KBi |
#9 |
Correcto
|
0.001 s | 0 KBi |
#10 |
Correcto
|
0.002 s | 1 KBi |
#11 |
Correcto
|
0.002 s | 0 KBi |
#12 |
Tiempo límite excedido
|
1.087 s | 1 KBi |
#13 |
Tiempo límite excedido
|
1.056 s | 1 KBi |
#14 |
Tiempo límite excedido
|
1.006 s | 1 KBi |
#15 |
Correcto
|
0.128 s | 69 KBi |
#16 |
Tiempo límite excedido
|
1.099 s | 1 KBi |
#17 |
Tiempo límite excedido
|
1.07 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 = searchNextBiggest(arr, n, x); if(y == n) res[j] = y; else { res[j] = y; for(int k = y - 1; k >= 0; k--) { if(arr[k] > x) res[j] = k; else break; } } } printArray(res, c); return 0; }