|
||||||||||
Coach Yehr¡¯s punishmentTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 640 Accepted Submission(s): 149 Problem Description During the Mult-University Trainging,Coach Yehr asks all the ACM teammates to jog at 6:30AM.But 6:30 is too early,there are always somebody might be late.Coach Yehr likes AC sequence very much,the AC sequence is a number sequence with all the elements different.A sequence (S1 ,S2 ,S3 ¡¡Sn ) is a AC sequence if S1 ,S2 ,S3 ¡¡Sn are all different. There are N teammates,the time(in second time) every teammate¡¯arrival make a number sequence with length N. In order to punish the laters,Coach Yehr give them a puzzle,Coach Yehr choose a subsequence from Sa to Sb ,the laters must tell Coach Yehr the longest length of AC sequence in the subsequence as soon as possible. Input There are multiply text cases.You must deal with it until the end of file. The first line of each test case is an interger N,indicates the number of ACM teammates; The second line have N intergers,the i-th number indicates the i-th teammate¡¯s arrival time. The third line is an interger M indicates Coach Yehr will ask M times; The follow M lines,each line have two intergers a and b,indicate the interval of the sequence. Output For each query,you have to print the longest length of AC sequence in the subsequence in a single line. Sample Input
Sample Output
Author dili Source | ||||||||||
|