-
Notifications
You must be signed in to change notification settings - Fork 84
/
James and the menus.py
51 lines (40 loc) · 1021 Bytes
/
James and the menus.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
'''
# Sample code to perform I/O:
name = input() # Reading input from STDIN
print('Hi, %s.' % name) # Writing output to STDOUT
# Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail
'''
# Write your code here
n,m = map(int,input().split())
lis = []
for i in range(n):
temp = list(map(int,input().split()))
lis.append(temp)
mx = [0]*m
su = [0]*n
for i in range(n):
for j in range(m):
mx[j] = max(mx[j],lis[i][j])
su[i] += lis[i][j]
cn = [0]*n
goodNumber = 0
for i in range(n):
for j in range(m):
if mx[j] == lis[i][j]:
cn[i]+=1
goodNumber = max(goodNumber,cn[i])
index = []
for i in range(len(cn)):
if goodNumber == cn[i]:
index.append(i)
ansSum = 0
ansIndex = 0
if len(index)>1:
for i in range(len(index)):
temp = su[index[i]]/4
if temp>ansSum:
ansSum = temp
ansIndex = index[i]
print(ansIndex+1)
else:
print(index[0]+1)