Pagini recente » Cod sursa (job #3140164) | Cod sursa (job #1190544) | Cod sursa (job #1261251) | Cod sursa (job #200382) | Cod sursa (job #2510549)
#n a vazut planeta asa ceva
def generator(path):
word = ''
with open(path) as file:
while True:
char = file.read(1)
if char.isspace():
if word:
yield word
word = ''
elif char == '':
if word:
yield word
break
else:
word += char
nr = generator("elmaj.in")
n= next(nr)
g = open("elmaj.out","w+")
#print(t)
dict = {}
ok = 0
maxel=[0,0]
for a in nr:
if a not in dict:
dict[a]=1
else:
dict[a]+=1
for k,v in dict.items():
if v>maxel[1]:
maxel[0] = k
maxel[1] = v
if maxel[1] > int(n)//2:
g.write(maxel[0] + " " + str(maxel[1]) + '\n')
else:
g.write("-1\n")
g.close()