Pagini recente » Cod sursa (job #836270) | Cod sursa (job #213993) | Cod sursa (job #2413838) | Cod sursa (job #980822) | Cod sursa (job #2510542)
from pathlib import Path
#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
for a in nr:
if a not in dict:
dict[a]=1
else:
dict[a]+=1
if dict[a] > int(n)//2:
ok=1
g.write(a+ " " + str(dict[a]) + '\n')
break
if ok==0:
g.write("-1\n")
g.close()