fork(1) download
  1. import sys
  2.  
  3. # from https://ru.stackoverflow.com/q/793871/23044
  4. fin = sys.stdin
  5. fout = sys.stdout
  6.  
  7. reader = fin.readlines()
  8. parties = []
  9. vote = []
  10. votes = 0
  11. for i in reader:
  12. if i == 'VOTES:\n':
  13. votes = 1
  14. if votes == 0:
  15. parties.append(i)
  16. else:
  17. vote.append(i)
  18. parties.pop(0)
  19. vote.pop(0)
  20. parties = [line.rstrip() for line in parties]
  21. vote = [line.rstrip() for line in vote]
  22. partwin = [0] * len(parties)
  23. total = 0
  24. for j in range(len(parties)):
  25. for k in range(len(vote)):
  26. if parties[j] == vote[k]:
  27. partwin[j] += 1
  28. total += 1
  29. total *= 0.07
  30. for m in range(len(partwin)):
  31. if partwin[m] >= total:
  32. print(parties[m], file=fout)
  33. fout.close()
Runtime error #stdin #stdout #stderr 0.02s 9340KB
stdin
PARTIES:
Party one
VOTES: something
Party one
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "./prog.py", line 19, in <module>
IndexError: pop from empty list