code-streak

Ronit is working on HackerEarth Profile. Right now he is working on User Statistics.
One of the statistics data (Code Streak) is as follows:

Given the User Activity Data, find the maximum number of continuous correct solutions submitted by any user.
Seems easy eh? Here's the catch! In order to maximize this number a user could have submitted a correct answer to the same problem which he has already solved. Now such cases cannot be tolerated. (See test case for clarification). 
Also in all the continuous correct submissions multiple correct submissions to same problem should be counted only once.

User Activity Data will be as follows:
Total number of submissions by the user - N
For each submission its Submission ID - S and Result - R (Solved or Unsolved) will be given.
Solved is represented by integer 1 and Unsolved by 0.

Input:
First line contains integer T - number of test cases. T test cases follow. First line of each test case will contain N. Next N lines each will contain two space separated integers S and R.

Ouput:
For each test case output in a single line the required answer.

Constraints:
1 ≤ T ≤ 1000
1 ≤ N ≤ 1000000 (106)
1 ≤ S ≤ 1000000 (106)
0 ≤ R ≤ 1

SAMPLE INPUT
3
6
1 0
2 1
3 1
4 1
5 1
6 0
5
1 1
2 0
3 1
1 1
2 1
4
1 1
2 1
2 1
3 1

SAMPLE OUTPUT
4
2
3

Source: hackerearth | Difficulty: EASY


Solutions:
noOfTestCases = int(input())


def maxSequence(lis):
	excludeList = {}
	counts = []
	count = 0
	for n in lis:
		#print n
		if(n[1] == '1' and (n[0] in excludeList) == False):
			count += 1
			excludeList[n[0]] = 1
		elif(n[1] == '0'):
			counts.append(count)
			count = 0
	
	if(lis[len(lis) - 1][1] == '1'):
		counts.append(count)
	print(max(counts))		

for caseNo in range(1, noOfTestCases + 1):
	count = int(input())
	lis = []
	for c in range(1, count + 1):
		lis.append(input().split(" "))
	maxSequence(lis)


import sys

for __ in range(eval(input())) :
	n = eval(input())
	has , ans , temp = {} , 0 , 0
	for _ in range(n) :
		a , b = list(map(int,sys.stdin.readline().split()))
		if a in has :
			if b == 0 :
				ans = max(ans,temp)
				temp = 0
		else :
			if b==1 :
				has[a] = b
				temp += 1
			else :
				ans = max(ans,temp)
				temp = 0
	print(max(ans,temp))
	


noOfTestCases = int(input())


def maxSequence(lis):
	excludeList = {}
	counts = []
	count = 0
	for n in lis:
		#print n
		if(n[1] == '1' and (n[0] in excludeList) == False):
			count += 1
			excludeList[n[0]] = 1
		elif(n[1] == '0'):
			counts.append(count)
			count = 0
	
	if(lis[len(lis) - 1][1] == '1'):
		counts.append(count)
	print(max(counts))		

for caseNo in range(1, noOfTestCases + 1):
	count = int(input())
	lis = []
	for c in range(1, count + 1):
		lis.append(input().split(" "))
	maxSequence(lis)