View Code of Problem 134

#include <iostream>
#include <algorithm>
using namespace std;

int main(){
  int n,q,a,b,size;
  while(scanf("%d",&n)!=EOF){
    int num[100001],buf[100001];
    for(int j=1;j<=n;j++){
      scanf("%d",&num[j]);
    }
    scanf("%d",&q);
    for(int j=0;j<q;j++){
      scanf("%d%d",&a,&b);
      size==0;
      for(int k=a;k<=b;k++){
        buf[size++] = num[k];
      }
      sort(buf,buf+size);
      printf("%d",buf[0]);
    }
  }
  return 0;
}

Double click to view unformatted code.


Back to problem 134