Problem:


Sale Result

There is data on sales of your company. Your task is to write a program which identifies good workers.

The program should read a list of data where each item includes the employee ID i, the amount of sales q and the corresponding unit price p. Then, the program should print IDs of employees whose total sales proceeds (i.e. sum of p &times; q) is greater than or equal to 1,000,000 in the order of inputting. If there is no such employees, the program should print "NA". You can suppose that n < 4000, and each employee has an unique ID. The unit price p is less than or equal to 1,000,000 and the amount of sales q is less than or equal to 100,000.

Input

The input consists of several datasets. The input ends with a line including a single 0. Each dataset consists of:

n (the number of data in the list)
i p q
i p q
 :
 :
i p q

Output

For each dataset, print a list of employee IDs or a text "NA"

Sample Input

4
1001 2000 520
1002 1800 450
1003 1600 625
1001 200 1220
2
1001 100 3
1005 1000 100
2
2013 5000 100
2013 5000 100
0

Output for the Sample Input

1001
1003
NA
2013



Sample input:
4
1001 2000 520
1002 1800 450
1003 1600 625
1001 200 1220
2
1001 100 3
1005 1000 100
2
2013 5000 100
2013 5000 100
0


Sample output:
1001
1003
NA
2013

Submission status: Wrong Answer

Solution code:
while True:
    n = int(input())
    if n == 0: break

    data = {}
    ans = []
    for i in range(n):
        tmp = list(map(int, input().split(' ')))
        if tmp[0] in data:
            data[tmp[0]] += tmp[1] * tmp[2]
        else:
            data[tmp[0]] = tmp[1] * tmp[2]

    for k, v in data.items():
        if v >= 1000000:
            ans.append(str(k))

    if len(ans) == 0:
        print('NA')
    else:
        print('\n'.join(ans))

Submission status: Wrong Answer

Solution code:
while True:
    n = int(input())
    if n == 0: break

    data = {}
    ans = []
    for i in range(n):
        tmp = list(map(int, input().split(' ')))
        if tmp[0] in data:
            data[tmp[0]] += tmp[1] * tmp[2]
        else:
            data[tmp[0]] = tmp[1] * tmp[2]

    if max(data.values()) < 1000000:
        print('NA')
    else:
        for k in data.keys():
            if data[k] >= 1000000:
                print(k)

Submission status: Wrong Answer

Solution code:
while True:
    n = int(raw_input())
    if n == 0:
        break
    sale = {}    
    
    for i in range(n):
        n,p,q = map(int,raw_input().split())
        if n in sale:
            sale[n] += p * q
        else:
            sale[n] = p * q
         
    existflag = False
    for n in sale:
        if(sale[n] >= 1000000):
            print n
            existflag = True
    if(not existflag):
        print 'NA'

Submission status: Wrong Answer

Solution code:
while True:
    n = int(raw_input())
    if n == 0:
        break
    sale = {}    
    
    for i in range(n):
        j,p,q = map(int,raw_input().split())
        if j in sale:
            sale[j] += p * q
        else:
            sale[j] = p * q
         
    existflag = False
    for j in sale:
        if(sale[j] >= 1000000):
            print j
            existflag = True
    if(not existflag):
        print 'NA'

Submission status: Wrong Answer

Solution code:
class sresult():
 def judge(self,n):
  list={}
  list2=[]
  for i in range(0,n):
   str=raw_input()
   array=str.split(" ")
   no=int(array[0])
   x=no
   sale=int(array[1])
   sold=int(array[2])
   
   if x in list:
    list[no]+=sale*sold
    if list[no]>=1000000 and x not in list2:
     list2.append(no)
   else :
    list.update({x:sale*sold})
    
  for i in range(0,len(list2)):
   print list2[i]
  if len(list2)==0:
    print "NA"
  #print list
if __name__=="__main__":
 ans=sresult()
 while True:
  
  n=input()
  if n==0:
   break
  ans.judge(n)

Submission status: Wrong Answer

Solution code:
# Edit: 2014/09/25
# Lang: Python3
# Time: 0.xxs
#

if __name__ == "__main__":

    while True:
        d = {}
        n = int(input())
        if not n:
            break  # exit at n=0

        for i in range(n):
            s, p, m = map(int, input().strip("\n").split(" "))
            # s:社員番号, p:価格, m:販売戸数
            # print(s, p, m)

            if s in d:
                d[s] = d[s] + p * m
            else:
                d[s] = p * m

        cnt = 0
        for k, v in d.items():
            if v >= 1000000:
                print(k)
                cnt +=1
        if not cnt:
            print("NA")

        #print(d)

Submission status: Wrong Answer

Solution code:
# Edit: 2014/09/25
# Lang: Python3
# Time: 0.xxs
#

if __name__ == "__main__":

    while True:
        d = {}
        n = int(input())
        if not n:
            break  # exit at n=0

        for i in range(n):
            s, p, m = map(int, input().strip("\n").split(" "))
            # print(s, p, m)

            if s in d:
                d[s] += p * m
            else:
                d[s] = p * m

        cnt = 0
        for k, v in d.items():
            if v >= 1000000:
                print(k)
                cnt +=1
        if not cnt:
            print("NA")

        #print(d)

Submission status: Wrong Answer

Solution code:
import collections
while 1:
	li=collections.defaultdict(int)
	n=int(input())
	if n==0:
		break
	for i in range(n):
		(emp,prc,num)=list(map(int,input().split()))
		li[emp]+=prc*num
	tmp=True
	for i,j in li.items():
		if j>=1000000:
			print(i)
			tmp=False
	if tmp:
		print("NA")
	li.clear()

Submission status: Wrong Answer

Solution code:
def f(n):
  D={}
  for _ in range(n):
    a,b,c=map(int,raw_input().split(' '))
    if a in D: D[a]+=b*c
    else: D[a]=b*c
  B=[e for e in D.keys() if D[e]>=1e6]
  if B==[]: B=["NA"]
  return B
 
while 1:
  n=input()
  if n==0:break
  for e in f(n): print e

Submission status: Wrong Answer

Solution code:
def f(n):
  D={}
  for _ in range(n):
    a,b,c=map(int,raw_input().split(' '))
    if a in D: D[a]+=b*c
    else: D[a]=b*c
  B=[i for i,e in D.items() if e>=1e6]
  if B==[]: B=["NA"]
  return B
 
while 1:
  n=input()
  if n==0:break
  for e in f(n): print e

Submission status: Wrong Answer

Solution code:
while True:
	n=int(input())
	if n:
		f=True
		a=[list(map(int,input().split())) for _ in range(n)]
		for i in range(n):
			if a[i][1]*a[i][2]>=1000000:
				print(a[i][0])
				f=False
		if f:
			print("NA")
	else:
		break

Submission status: Wrong Answer

Solution code:
while True:
	n=int(input())
	if n:
		a=[list(map(int,input().split())) for _ in range(n)]
		b={}
		for i in range(n):
			if a[i][0] in b:
				b[a[i][0]]+=a[i][1]*a[i][2]
			else:
				b[a[i][0]]=a[i][1]*a[i][2]
		for k in b.keys():
			if b[k]>=1000000:
				print(k)
		if max(b.values())<1000000:
			print("NA")
	else:
		break

Submission status: Wrong Answer

Solution code:
while True:
	n=int(input())
	if n:
		a=[list(map(int,input().split())) for _ in range(n)]
		d={}
		for i in range(n):
			if a[i][0] in d:
				d[a[i][0]]+=a[i][1]*a[i][2]
			else:
				d[a[i][0]]=a[i][1]*a[i][2]
		print(d)
		for k in d.keys():
			if d[k]>=1000000:
				print(k)
		if max(d.values())<1000000:
			print("NA")
	else:
		break

Submission status: Wrong Answer

Solution code:
while True:
	n=int(input())
	if n:
		a=[list(map(int,input().split())) for _ in range(n)]
		d={}
		for i in range(n):
			if a[i][0] in d:
				d[a[i][0]]+=a[i][1]*a[i][2]
			else:
				d[a[i][0]]=a[i][1]*a[i][2]
		for k in d.keys():
			if d[k]>=1000000:
				print(k)
		if max(d.values())<1000000:
			print("NA")
	else:
		break

Submission status: Wrong Answer

Solution code:
while True:
	n=int(input())
	if n==0: break
	a=[list(map(int,input().split())) for _ in range(n)]
	d={}
	for i in range(n):
		if a[i][0] in d:
			d[a[i][0]]+=a[i][1]*a[i][2]
		else:
			d[a[i][0]]=a[i][1]*a[i][2]
	for k in d.keys():
		if d[k]>=1000000:
			print(k)
	if max(d.values())<1000000:
		print("NA")

Submission status: Wrong Answer

Solution code:
while True:
	n=int(input())
	if n==0: break
	d={}
	for i in range(n):
		a,b,c=list(map(int,input().split()))
		if a in d:
			d[a]+=b*c
		else:
			d[a]=b*c
	if max(d.values())<1000000:
		print("NA")
	else:
		for k in d.keys():
			if d[k]>=1000000:
				print(k)

Submission status: Wrong Answer

Solution code:
def f(n):
  D = {}
  for _ in [0]*n:
    a,b,c = map(int,raw_input().split(' '))
    try: D[a] += b*c
    except: D[a] = b*c
  B = [i for i,e in D.items() if e>=1e6]
  if not B: B=["NA"]
  return B
 
while 1:
  n = int(raw_input())
  if n==0: break
  for e in f(n): print e

Submission status: Wrong Answer

Solution code:
def f(n):
  D = {}
  for _ in [0]*n:
    a,b,c = map(int,raw_input().split(' '))
    try: D[a] += b*c
    except: D[a] = b*c
  B = [i for i,e in D.items() if e>=1e6]
  if B==[]: B=["NA"]
  return B
 
while 1:
  n = int(raw_input())
  if n==0: break
  for e in f(n): print e

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
while True:
    n = int(raw_input())
    if n == 0:
        break
    else:
        IDdic={}
        for k in range(n):  
            ID, p, q = map(int,raw_input().split())
            if ID not in IDdic:
                IDdic[ID] = p*q
            elif ID in IDdic:
                IDdic[ID] +=  p*q

        # IDの出現順はまだ考慮していない。
        for key in IDdic.keys():
            m=0
            if IDdic[key] >=1000000 :
                m+=1
                print key
            if m==0:
                print "NA"

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
while True:
    n = int(raw_input())
    if n == 0:
        break
    else:
        IDdic={}
        for k in range(n):  
            ID, p, q = map(int,raw_input().split())
            if ID not in IDdic:
                IDdic[ID] = [k, p*q]
            elif ID in IDdic:
                IDdic[ID][1] += p*q

        # IDの出現順はIDdic[ID][0] (=k)で確認できる
        temp = []        
        for key in IDdic.keys():
            m=0
            if IDdic[key][1] >=1000000 :
                m+=1
                temp.append((IDdic[key][0],key))
                temp.sort()
                for sortedID in temp:
                    print sortedID[1]
            if m==0:
                print "NA"

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
while True:
    n = int(raw_input())
    if n == 0:
        break
    else:
        IDdic={}
        for k in range(n):  
            ID, p, q = map(int,raw_input().split())
            if ID not in IDdic:
                IDdic[ID] = [k, p*q]
            elif ID in IDdic:
                IDdic[ID][1] += p*q

        # IDの出現順はIDdic[ID][0] (=k)で確認できる
        temp = []        
        for key in IDdic.keys():
            m=0
            if IDdic[key][1] >=1000000 :
                m+=1
                temp.append((IDdic[key][0],key))
                temp=sorted(temp)
        for sortedID in temp:
            print sortedID[1]
        if m==0:
            print "NA"

Submission status: Wrong Answer

Solution code:
while True:
    try:
        n=int(input())
    except:
        break
    if n==0:
        break
    data=[]
    for i in range(n):
        spam=[x for x in map(int,input().split())]
        if spam[1]*spam[2]>=1000000:
            if (spam[0] in [b[0] for b in data])==False:
                data.append(spam)
    if len(data)==0:
        print('NA')
    else:
        for i in [b[0] for b in data]:
            print(i)

Submission status: Wrong Answer

Solution code:
while 1:
	n = int(raw_input())
	if n == 0:
		break
	for i in range(n):
		x, y, z = map(int, raw_input().split())
		if y*z >= 1000000:
			print x
		else:
			print "NA"

Submission status: Wrong Answer

Solution code:
while True:
    num = int(raw_input())
    if num == 0: exit()

    d = {}
    cnt = 0
    for i in range(num):
        uid, p, q = map(int, raw_input().split(" "))
        if d.has_key(uid): d[uid] += p * q
        else: d[uid] = p * q

    sorted(d.items())
    for i in d:
        if d[i] >= 1000000:
            print i
            cnt += 1
    if cnt == 0: print "NA"

Submission status: Wrong Answer

Solution code:
while True:
    num = int(raw_input())
    if num == 0: exit()

    d = {}
    for i in range(num):
        uid, p, q = map(int, raw_input().split())
        if d.has_key(uid): d[uid] += p * q
        else: d[uid] = p * q

    if max(d.values()) < 1000000: print "NA"
    else:
        reversed(d.items())
        for i in d:
            if d[i] >= 1000000: print i

Submission status: Wrong Answer

Solution code:
while True:
    n=int(input())
    if n==0:break

    data={}
    staff=[]
    for i in range(n):
        tmp=list(map(int,input().split(' ')))
        if tmp[0] in data:
            data[tmp[0]]+=tmp[1]*tmp[2]
        else:
            data[tmp[0]]=tmp[1]*tmp[2]
            staff.append(tmp[0])

        if max(data.values())<1000000:
            print('NA')
        else:
            for k in staff:
                if data[k]>=1000000:
                    print(k)

Submission status: Wrong Answer

Solution code:
N = int(raw_input())
dic = {}
for i in range(N):
    n, p, q = map(int, raw_input().split())
    if not n in dic:
        dic[n] = [i,p*q]
    else:
        dic[n][1] = dic[n][1]+p*q
        
lis = [(v[0], k) for k, v in dic.items() if v[1] >= 1000000]
if lis:
    for t in sorted(lis, key=lambda x: x[0]):
        print t[1]
else:
    print 'NA'

Submission status: Wrong Answer

Solution code:
while True:
	n = int(raw_input())
	if n == 0:
		break
	
	dict = {}
	list = []
	for i in xrange(n):
		a,b,c = map(int,raw_input().split())
		
		if a in dict:
			dict[a] = dict[a] + b * c
		else:
			dict[a] = b * c
			
	for var in dict:
		if dict[var] >= 1000000:
			list.append(var)
			
	if len(list) == 0:
		list.append("NA")
			
	for var in list:
		print var

Submission status: Wrong Answer

Solution code:
while True:
	n = int(raw_input())
	if n == 0:
		break
	dict = {}
	for i in xrange(n):
		num,a,b = map(int,raw_input().split())
		if num in dict:
			dict[num] += a * b
		else:
			dict[num] = a * b
	
	judge = True
	for var in dict:
		if dict[var] >= 1000000:
			print var
			judge = False
	
	if judge:
		print "NA"

Submission status: Wrong Answer

Solution code:
while True:
	n = int(raw_input())
	if n == 0:
		break
	dict = {}
	for i in xrange(n):
		num,a,b = map(long,raw_input().split())
		if num in dict:
			dict[num] += a * b
		else:
			dict[num] = a * b
	
	judge = True
	for var in dict:
		if dict[var] >= 1000000:
			print var
			judge = False
	
	if judge:
		print "NA"

Submission status: Wrong Answer

Solution code:
while True:
	n = int(raw_input())
	if n == 0:
		break
	dict = {}
	for i in xrange(n):
		num,a,b = map(long,raw_input().split())
		if num in dict:
			dict[num] += a * b
		else:
			dict[num] = a * b
	
	judge = True
	for var in dict:
		if dict[var] >= 1000000L:
			print var
			judge = False
	
	if judge:
		print "NA"
	print dict

Submission status: Wrong Answer

Solution code:
import sys
from collections import OrderedDict

data = OrderedDict()                                                              
for line in sys.stdin:                     
    lst = line.split(' ')
            
    if len( lst ) < 2:
        cnt = 0            
        for key, val in data.items():
            if val >= 1000000:
                print key
                cnt = cnt + 1
                                               
        if len( data ) != 0 and cnt == 0:
            print "N/A"
                                               
        if lst[0] == 0:
            break
                                                         
        data = OrderedDict()
        continue
                                                  
    lst = map(int, lst)
    if lst[0] in data:
        data[ lst[0] ] = data[ lst[0] ] + lst[1]*lst[2]
    else:
        data[ lst[0] ] = lst[1]*lst[2]

sys.exit(0)

Submission status: Wrong Answer

Solution code:
import sys
def func(num):
   dict = {}
   for i in range(len(num)):
       if num[i][0] not in dict.keys():
           dict[num[i][0]] = int(num[i][1]) * int(num[i][2])
       else:
           dict[num[i][0]] = dict[num[i][0]] + int(num[i][1]) * int(num[i][2])
   list = dict.keys()
   flag = 0
   for i in list:
       if dict[i] >= 1000000:
           print(i)
           flag = 1
   if flag == 0:
       print("NA")
flag = 0
count = 0
n = 0
num = []
for line in sys.stdin.readlines():
   if flag == 0:
       n = int(line)
       if n == 0:
           break
       flag = 1
       count = 0
   elif flag == 1:
       count += 1
       num.append(line.split())
       if count == n:
           flag = 0
           func(num)
           del(num)
           num = []

Submission status: Wrong Answer

Solution code:
while True:
	n = int(raw_input())
	if n == 0:
		break
	employee_no = []
	info = {}
	for r in range(n):
		no,unit_price,quantity = map(int, raw_input().split(' '))
		if no in info:
			info[no] += unit_price*quantity
		else:
			info[no] = unit_price*quantity
		employee_no.append(no)
	employee_no = list(set(employee_no))
	output_flg = False
	for no in employee_no:
		if info[no] >= 10**6:
			output_flg = True
			print no
	if not output_flg:
		print "NA"

Submission status: Wrong Answer

Solution code:
while True:
  n = int(input())
  if n == 0:
    break
  c = 0
  d = {}
  for i in range(n):
    num,x,y = map(int,input().split())
    if num in d:
      d[num] = d[num] + x*y
    else:
      d[num] = x*y
  for i in d:
    if d[i] >= 1000000:
      print(i)
      c += 1
  if c == 0:
    print('NA')

Submission status: Wrong Answer

Solution code:
while True:
    N = int(input())
    if N == 0:
        break
    fla = False
    for n in range(N):
        num, p, q = map(int, input().split())
        if p*q >= 1000000:
            print(num)
            fla = True
    else:
        if not fla:
            print('NA')

Submission status: Wrong Answer

Solution code:
num = int(input())
if not num:
    exit()
data = [[int(el) for el in input().split(' ')] for _ in range(num)]
result = [print(i) for i,j,k in data if j*k >= 1e6]
if not result:
    print('NA')

Submission status: Wrong Answer

Solution code:
while True:
    num = int(input())
    if not num:
        break
    data = [[int(el) for el in input().split(' ')] for _ in range(num)]
    result = [print(i) for i,j,k in data if j*k >= 1e6]
    if not result:
        print('NA')

Submission status: Wrong Answer

Solution code:
while True:
    num = int(input())
    if not num:
        break
    data = [[int(el) for el in input().split(' ')] for _ in range(num)]
    tmp = [i for i,j,k in data if j*k >= 1e6]
    seen = set()
    seen_add = seen.add
    result = [x for x in tmp if x not in seen and not seen_add(x)]
    if not result:
        print('NA')
    else:
        [print(r) for r in result]

Submission status: Wrong Answer

Solution code:
while True:
    try:
        num = int(input())
    except:
        break
    data = [[int(el) for el in input().split(' ')] for _ in range(num)]
    tmp = [i for i,j,k in data if j*k >= 1e6]
    seen = set()
    seen_add = seen.add
    result = [x for x in tmp if x not in seen and not seen_add(x)]
    if not result:
        print('NA')
    else:
        [print(r) for r in result]

Submission status: Wrong Answer

Solution code:
while True:
    num = int(input())
    if not num: break
    result = {}
    for _ in range(num):
        x, y, z = [int(el) for el in input().split(' ')]
        if x in result:
            result[x] += y*z
        else:
            result[x] = y*z
    res = [print(k) for k,v in result.items() if v >= 1e6]
    if not res: print('NA')

Submission status: Wrong Answer

Solution code:
while True:
    n = int(input())
    if n == 0: break
  
    data = {}
    for i in range(n):
        tmp = list(map(int, input().split(' ')))
        if tmp[0] in data:
            data[tmp[0]] += tmp[1] * tmp[2]
        else:
            data[tmp[0]] = tmp[1] * tmp[2]
  
    if max(data.values()) < 1000000:
        print('NA')
    else:
        for k,v in data.items():
            if v >= 1000000:
                print(k)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys

input_lines = sys.stdin.readlines()
cnt = 0
dataset = []
for i in input_lines:
    print('s')

Submission status: Wrong Answer

Solution code:
while 1:
    n=input()
    if n==0:break
    a=[0]*n
    s=[]
    for i in xrange(n):
        a[i]=map(int,raw_input().split())
    for i in xrange(n):
        if a[i][1]*a[i][2]>=10**6:
            s.append(a[i][0])
        else:
            pass
    if s==[]:
        print("NA")
    else:
        for i in xrange(len(s)):
            print(s[i])

Submission status: Wrong Answer

Solution code:
n = int(raw_input())
while n != 0:
    pass_flag = 0
    for x in range(0, n):
        data = raw_input()
        data_list = data.split(' ')
        if int(data_list[1]) * int(data_list[2]) >= 1000000:
            pass_flag = 1
            print data_list[0]
    if pass_flag == 0:
        print 'NA'
    n = int(raw_input())

Submission status: Wrong Answer

Solution code:
n = int(raw_input())
while n != 0:
    pass_flag = 0
    sales_dict = {}
    for x in range(0, n):
        data = raw_input()
        data_list = data.split(' ')
        if not sales_dict.has_key(data_list[0]):
            sales_dict[data_list[0]] = int(data_list[1]) * int(data_list[2])
        else:
            sales_dict[data_list[0]] += int(data_list[1]) * int(data_list[2])
    for x in sales_dict.keys():
        if  sales_dict[x] >= 1000000:
            print x
            pass_flag = 1
    if pass_flag == 0:
        print 'NA'
    n = int(raw_input())

Submission status: Wrong Answer

Solution code:
n = int(raw_input())
while n != 0:
    pass_flag = 0
    sales_dict = {}
    for x in range(0, n):
        data = raw_input()
        data_list = map(int, data.split(' '))
        if not sales_dict.has_key(data_list[0]):
            sales_dict[data_list[0]] = data_list[1] * data_list[2]
        else:
            sales_dict[data_list[0]] += data_list[1] * data_list[2]
    for x in sales_dict.keys():
        if  sales_dict[x] >= 1000000:
            print x
            pass_flag = 1
    if pass_flag == 0:
        print 'NA'
    n = int(raw_input())

Submission status: Wrong Answer

Solution code:
n = int(raw_input())
while n != 0:
    pass_flag = 0
    sales_dict = {}
    for x in range(0, n):
        data = raw_input()
        data_list = map(int, data.split(' '))
        if not data_list[0] in sales_dict:
            sales_dict[data_list[0]] = data_list[1] * data_list[2]
        else:
            sales_dict[data_list[0]] += data_list[1] * data_list[2]
    for x in sales_dict.keys():
        if  sales_dict[x] >= 1000000:
            print x
            pass_flag = 1
    if pass_flag == 0:
        print 'NA'
    n = int(raw_input())

Submission status: Wrong Answer

Solution code:
while True:
    a = int(input())
    if a == 0:
        break
    lib = {}
    
    for _ in range(a):
        s,m,l = map(int, input().split())
        lib[s] = lib.get(s,0) + m*l
    
    if max(lib[x] for x in lib) <1000000:
        print("NA")
    else:
        for i in lib:
            if lib[i] >= 1000000:
                print(i)

Submission status: Wrong Answer

Solution code:
while True:
    a = int(input())
    if a == 0:
        break
    lib = {}
    
    for _ in range(a):
        s,m,l = map(int, input().split())
        lib[s] = lib.get(s,0) + m*l
    
    if max(lib[x] for x in lib) <1000000:
        print("NA")
    else:
        for i in lib:
            if lib[i] >= 1000000:
                print(i)

Submission status: Wrong Answer

Solution code:
while True:
    a = int(input())
    if a == 0:
        break
    lib = [0]*4000
    
    for _ in range(a):
        s,m,l = map(int, input().split())
        lib[s-1] +=  m*l
    
    if max(lib) <1000000:
        print("NA")
    else:
        for i in range(4000):
            if lib[i] >= 1000000:
                print(i+1)

Submission status: Wrong Answer

Solution code:
lib = [0] * 4000

while True:
    a = int(input())
    if a == 0:
        break
    
    for _ in range(a):
        s,m,l = map(int, input().split())
        lib[s-1] +=  m*l
    
    if max(lib) <1000000:
        print("NA")
    else:
        for i in range(4000):
            if lib[i] >= 1000000:
                print(i+1)
    for i in range(4000):
        lib[i] = 0

Submission status: Wrong Answer

Solution code:

while True:
    n = int(input())
    if n != 0:
        dic = {}
        initno,initprice,initsales = map(int,input().split(" "))
        total = initsales*initprice
        dic[initno] = total
        for i in range(n-1):
            no, price, sales = map(int, input().split(" "))
            for k,v in dic.items():
                if k == no:
                    dic[no] = total
                    dic[no] = total + price*sales
                    break
                else:
                    dic[no] = price*sales
                    break
        cnt = 0
        for k,v in sorted(dic.items(),reverse=True):
            if v >= 1000000:
                print("%d" %(k))
                cnt += 1
            else:
                pass

        if cnt == 0:
            print("NA")
    else:
        break

Submission status: Wrong Answer

Solution code:

while True:
    n = int(input())
    if n != 0:
        dic = {}
        initno,initprice,initsales = map(int,input().split(" "))
        total = initsales*initprice
        dic[initno] = total
        for i in range(n-1):
            no, price, sales = map(int, input().split(" "))
            for k,v in dic.items():
                if k == no:
                    dic[no] = total
                    dic[no] = total + price*sales
                    break
                else:
                    dic[no] = price*sales
                    break
        cnt = 0
        for k,v in sorted(dic.items()):
            if v >= 1000000:
                print("%d" %(k))
                cnt += 1
            else:
                pass

        if cnt == 0:
            print("NA")
    else:
        break

Submission status: Wrong Answer

Solution code:
while True:
    n = int(input())
    if n != 0:
        dic = {}
        initno,initprice,initsales = map(int,input().split(" "))
        total = initsales*initprice
        dic[initno] = total
        for i in range(n-1):
            no, price, sales = map(int, input().split(" "))
            for k,v in dic.items():
                if k == no:
                    dic[no] = total
                    dic[no] = total + price*sales
                    break
                else:
                    dic[no] = price*sales
                    break
        cnt = 0
        for k,v in sorted(dic.items()):
            if v >= 1000000:
                print("%s" %(k))
                cnt += 1
            else:
                pass

        if cnt == 0:
            print("NA")
    else:
        break

Submission status: Wrong Answer

Solution code:
while True:
    n = int(input())
    if n != 0:
        dic = {}
        initno,initprice,initsales = map(int,input().split(" "))
        total = initsales*initprice
        dic[initno] = total
        for i in range(n-1):
            no, price, sales = map(int, input().split(" "))
            for k,v in dic.items():
                if k == no:
                    dic[no] = total
                    dic[no] = total + price*sales
                    break
                else:
                    dic[no] = price*sales
                    break
        cnt = 0
        for k,v in sorted(dic.items()):
            if v >= 1000000:
                print("%s" %(str(k)))
                cnt += 1
            else:
                pass

        if cnt == 0:
            print("NA")
    else:
        break

Submission status: Wrong Answer

Solution code:
while True:
    n = int(input())
    if n != 0:
        dic = {}
        initno,initprice,initsales = map(int,input().split(" "))
        total = initsales*initprice
        dic[initno] = total
        for i in range(n-1):
            no, price, sales = map(int, input().split(" "))
            for k,v in dic.items():
                if k == no:
                    total = dic[no]
                    dic[no] = total + price*sales
                    break
                else:
                    dic[no] = price*sales
                    break
        cnt = 0
        for k,v in sorted(dic.items()):
            if v >= 1000000:
                print("%s" %(str(k)))
                cnt += 1
            else:
                pass

        if cnt == 0:
            print("NA")
    else:
        break

Submission status: Wrong Answer

Solution code:
while True:
    n = int(input())
    if n != 0:
        dic = {}
        initno,initprice,initsales = map(int,input().split(" "))
        total = initsales*initprice
        dic[initno] = total
        for i in range(n-1):
            no, price, sales = map(int, input().split(" "))
            for k,v in dic.items():
                if k == no:
                    total = dic[no]
                    dic[no] = total + price*sales
                    break
                else:
                    dic[no] = price*sales
                    break


        cnt = 0
        for k,v in sorted(dic.items()):
            if v >= 1000000:
                print("%s" %(str(k)))
                cnt += 1
            else:
                pass

        if cnt == 0:
            print("NA")
        else:
            pass
    else:
        break

Submission status: Wrong Answer

Solution code:
while True:
    num=int(input())
    if num==0:
        break
    else:
        d={}
        for i in range (num):
            info=list(map(int,input().split()))
            try:
                d[info[0]]+=info[1]*info[2]
            except:
                d[info[0]]=info[1]*info[2]
    answer=[]
    for i in d.keys():
        if d[i] >=1000000:
            answer.append(i)
    answer=sorted(answer)
    if answer==[]:
        print("NA")
    else:
        for i in answer:
            print(i)

Submission status: Wrong Answer

Solution code:
num=int(input())
emp=[]
cnt=0
for i in range(num):
    emp.append(num)
    emp[i]=[int(k) for k in input().split()]
for i in range(num):
    for q in range(i+1,num):
        if emp[i][0]==emp[q][0]:
            emp[i][1]=emp[i][1]+emp[q][1]
            emp[i][2]=emp[i][2]+emp[q][2]
            emp[q][1],emp[q][2]=0,0
    if emp[i][1]*emp[i][2]>=1000000:
        print(emp[i][0])
        cnt+=1
if cnt==0:
    print('NA')

Submission status: Wrong Answer

Solution code:
while True:
	n = int(input())
	if n == 0:
		break
	else:
		greatworkers = []
		for i in range(n):
			person, price, number = [int(i) for i in input().split()]
			if price * number >= 1000000:
				greatworkers.append(str(person))
		if greatworkers == []:
			print('NA')
		else:
			print('\n'.join(greatworkers))

Submission status: Wrong Answer

Solution code:
while True:
	n = int(input())
	if n == 0:
		break
	else:
		greatworkers = []
		for i in range(n):
			person, price, number = [int(i) for i in input().split()]
			if person in greatworkers:
				pass
			elif price * number >= 1000000:
				greatworkers.append(str(person))
		if greatworkers == []:
			print('NA')
		else:
			print('\n'.join(greatworkers))

Submission status: Wrong Answer

Solution code:
while True:
	n = int(input())
	if n == 0:
		break
	workers = {}
	greatworkers = 0
	for i in range(n):
		person, price, number = map(int, input().split())
		if person in workers:
			workers[person] += price * number
		else:
			workers[person] = price * number
	for worker in workers:
		if workers[worker] >= 1000000:
			print(worker)
			greatworkers += 1	
	if greatworkers == 0:
		print('NA')