Cod sursa(job #2768472)

Utilizator helloworld0107Iordachi Bianca helloworld0107 Data 10 august 2021 22:33:41
Problema Range minimum query Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.43 kb
#include <bits/stdc++.h>
 
 using namespace std;
 
int main()
{
    
    freopen("rmq.in", "r", stdin);
    freopen("rmq.out", "w", stdout);
    
    
    int m, n, x, y, a[100001], t = 100000;
    cin >> n >> m;
    
    for (int i = 1; i <= n; i++)
    cin >> a[i];
    
    for (int i = 1; i <= m; i++)
    {
        cin >> x >> y;
        
    for (int j = x; j <= y; j++)
     { if( a[j] < t) t = a[j]; }
    cout << t << "\n";
    }
}