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

Envío 6516

Problema 0x9b - Máximo elemento en un subarreglo pequeño

  • Autor: danidiaztech
  • Fecha: 2022-07-12 04:29:04 UTC (Hace más de 1 año)
Caso # Resultado Tiempo Memoria
#1
Incorrecto
0.001 s 0 KBi
#2
Incorrecto
0.002 s 0 KBi
#3
Incorrecto
0.002 s 0 KBi
#4
Incorrecto
0.002 s 0 KBi
#5
Incorrecto
0.002 s 0 KBi
#6
Incorrecto
0.002 s 0 KBi
#7
Incorrecto
0.003 s 0 KBi
#8
Incorrecto
0.002 s 0 KBi
#9
Incorrecto
0.002 s 0 KBi
#10
Incorrecto
0.002 s 0 KBi
#11
Incorrecto
0.006 s 1 KBi
#12
Incorrecto
0.002 s 0 KBi
#13
Incorrecto
0.005 s 0 KBi
Puntos totales: 0 / 100

Código

#include <bits/stdc++.h>

using namespace std;

int main(){
    #ifndef LOCAL
        // For getting input from input.txt file
        freopen("input.txt", "r", stdin);
    
        // Printing the Output to output.txt file
        freopen("output.txt", "w", stdout);
    #endif
    int n, l, r, c; 
    cin >> n;
    
    int arr[n];
    for (int i = 0; i < n; i++) cin >> arr[i];

    cin >> c;

    for (int i = 0; i < c; i++){
        cin >> l >> r;
        int building, maxh;
        building = maxh = 0;
        for (int j = l; j < r + 1; j++){
            if (arr[j] > maxh){
                maxh = arr[j];
                building = j;
            }
        }
        cout << building << endl;
    }


    return 0;
}