Skip to content

Instantly share code, notes, and snippets.

@beholderrk
Created January 2, 2014 20:21
Show Gist options
  • Save beholderrk/8226049 to your computer and use it in GitHub Desktop.
Save beholderrk/8226049 to your computer and use it in GitHub Desktop.
http://informatics.mccme.ru/moodle/mod/statements/view3.php?id=270&chapterid=1440#1 Спортсмен Василий участвовал в соревнованиях по хоккейболу и получил в личном зачете серебряную медаль. Известно, что участники, получившие одинаковое количество очков, награждаются одинаковыми наградами. Известно, что были разыграны золотые серебряные и бронзовы…
# task1440.py
n = int(raw_input(''))
scores = raw_input('')
scores = [ int(x) for x in scores.split(' ') if x ]
max1 = max(scores[0], scores[1])
max2 = min(scores[0], scores[1])
for i in xrange(2, len(scores)):
if scores[i] > max1:
max2 = max1
max1 = scores[i]
elif scores[i] > max2 and max1 != scores[i]:
max2 = scores[i]
elif max1 == max2:
max2 = scores[i]
print max2
@beholderrk
Copy link
Author

задачу нужно решить без сортировок и set, как-то коряво получилось

@Qscfthn
Copy link

Qscfthn commented Jul 31, 2015

Зачем последние условие? Результаты не могут совпадать, исходя из других условий.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment