Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

TLE???why???

Posted by swordl3 at 2012-07-08 17:34:34 on Problem 3264
#include <stdio.h>
#include <iostream>
using namespace std;
int main()
{
	int i,n,q,a[500000],min,max,low,high;
	cin>>n>>q;
	for (i=0;i<n;i++)
	{
		cin>>a[i];
	}
	while(q--)
	{
		cin>>low>>high;
		min=100000;
		max=-100000;
		for(i=low-1;i<high;i++)
		{
			if(min>a[i])
			{
				min=a[i];
			}
			if(max<a[i])
			{
				max=a[i];
			}
		}
		cout<<(max-min)<<"\n";
	}
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator