Skip to content

Instantly share code, notes, and snippets.

@zsrinivas
Created May 26, 2014 08:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zsrinivas/11d8d78312734fc00557 to your computer and use it in GitHub Desktop.
Save zsrinivas/11d8d78312734fc00557 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <assert.h>
#include <ctype.h>
int lane[100010];
int min(int pint, int pont);
int main(int argc, char const *argv[])
{
int n,testc,i,j;
scanf("%d%d", &n,&testc);
for (i = 0; i < n; ++i)
scanf("%d", &lane[i]);
while(testc--)
{
scanf("%d%d", &i,&j);
printf("%d\n", min(i,j));
}
return 0;
}
int min(int pint, int pont)
{
int i,mini=lane[pint];
for (i = pint+1; i <= pont; ++i)
if (mini>lane[i])
mini=lane[i];
return mini;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment