█████████ ████ ███░░░░░███ ░░███ ███ ░░░ ██████ ███████ ██████ ██████ ░███ ███░░███ ███░░███ ███░░███ ███░░███ ░███ ░███ ░███░███ ░███ ░███████ ░███ ░███ ░░███ ███░███ ░███░███ ░███ ░███░░░ ░███ ░███ ░░█████████ ░░██████ ░░████████░░██████ ░░██████ ░░░░░░░░░ ░░░░░░ ░░░░░░░░ ░░░░░░ ░░░░░░

Envío 7182

Problema 0x63 - Encontrar el primer elemento mayor a X en un arreglo ordenado

  • Autor: ppastram
  • Fecha: 2023-10-20 14:12:53 UTC (Hace 7 meses)
Caso # Resultado Tiempo Memoria
#1
Correcto
0.001 s 0 KBi
#2
Correcto
0.002 s 0 KBi
#3
Correcto
0.001 s 0 KBi
#4
Correcto
0.002 s 0 KBi
#5
Correcto
0.001 s 0 KBi
#6
Correcto
0.002 s 0 KBi
#7
Correcto
0.001 s 0 KBi
#8
Correcto
0.002 s 0 KBi
#9
Correcto
0.002 s 0 KBi
#10
Correcto
0.002 s 0 KBi
#11
Correcto
0.001 s 0 KBi
#12
Tiempo límite excedido
1.1 s 1 KBi
#13
Tiempo límite excedido
1.1 s 1 KBi
#14
Tiempo límite excedido
1.1 s 1 KBi
#15
Tiempo límite excedido
1.074 s 1 KBi
#16
Correcto
0.079 s 1 KBi
#17
Correcto
0.074 s 1 KBi
Puntos totales: 77 / 100

Código

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
using namespace std;

int main()
{
    int n, c, este;
    cin >> n;
    vector <int> lista;

    for(int i = 0; i < n; i++)
    {
        cin >> este;
        lista.push_back(este);
    }

    cin >> c;
    while(c--)
    {
        cin >> este;
        bool ya = false;
        for(int i = 0; i < n; i++)
        {
            if(lista[i] > este)
            {
                cout<<i<<endl;
                ya = true;
                break;
            }
        }
        if(!ya) cout << n << endl;
    }
}