Last active
November 4, 2015 11:13
-
-
Save ZeronSix/39df56775b6429a1c5b4 to your computer and use it in GitHub Desktop.
Олимпиада 2013-2014 10 класс
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with open("input.txt") as fi: | |
a = [int(s) for s in fi.readline().split()] | |
a.sort() | |
max_sum = -1 | |
max_index = -1 | |
for i in range(0, 3): | |
n = a[i] % 10 + (a[i] // 10) % 10 | |
if n > max_sum: | |
max_sum = n | |
max_index = i | |
with open("output.txt", "w") as fo: | |
fo.write(str(a[max_index])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
songs = [] | |
total_len = 0 | |
with open("input.txt") as fi: | |
l, n = [int(s) for s in fi.readline().split()] | |
for _ in range(n): | |
m, s = [int(x) for x in fi.readline().split()] | |
song_len = m * 60 + s | |
total_len += song_len | |
songs.append(song_len) | |
l %= total_len | |
length = 0 | |
for i in range(0, n): | |
length += songs[i] | |
if length >= l: | |
with open("output.txt", "w") as fo: | |
fo.write(str(i + 1)) | |
break |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with open("tests/05") as fi: | |
s = fi.readline() | |
s = s[0:len(s)-1] | |
n = 0 | |
i = 0 | |
while i < len(s): | |
if s[i] == "0": | |
i += 8 | |
else: | |
if s[i + 1] == "1": | |
if s[i + 2] == "1": | |
if s[i + 3] == "1": | |
if s[i + 4] == "1": | |
if s[i + 5] == "1": | |
i += 48 | |
else: | |
i += 40 | |
else: | |
i += 32 | |
else: | |
i += 24 | |
else: | |
i += 16 | |
n += 1 | |
with open("output.txt", "w") as fo: | |
fo.write(str(n)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with open("input.txt") as fi: | |
a, b = [int(s) for s in fi.readline().split()] | |
x0, y0 = [int(s) for s in fi.readline().split()] | |
vx, vy = [int(s) for s in fi.readline().split()] | |
t = -1 | |
if -a / 2 <= x0 <= a / 2 and -b / 2 <= y0 <= b / 2: | |
t = 0 | |
else: | |
if vx != 0: | |
nt = (-a / 2 - x0) / vx | |
if nt >= 0: | |
if -b / 2 <= y0 + vy * nt <= b / 2: | |
if nt < t or t == -1: | |
t = nt | |
nt = (a / 2 - x0) / vx | |
if nt >= 0: | |
if -b / 2 <= y0 + vy * nt <= b / 2: | |
if nt < t or t == -1: | |
t = nt | |
if vy != 0: | |
nt = (-b / 2 - y0) / vy | |
if nt >= 0: | |
if -a / 2 <= x0 + vx * nt <= a / 2: | |
if nt < t or t == -1: | |
t = nt | |
nt = (b / 2 - y0) / vy | |
if nt >= 0: | |
if -a / 2 <= x0 + vx * nt <= a / 2: | |
if nt < t or t == -1: | |
t = nt | |
with open("output.txt", "w") as fo: | |
fo.write(str(t)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
import sys | |
with open("input.txt") as fi: | |
n, m, s = [int(s) for s in fi.readline().split()] | |
b = [int(s) for s in fi.readline().split()] | |
l = [int(s) for s in fi.readline().split()] | |
d = [int(s) for s in fi.readline().split()] | |
if m == 0: | |
with open("output.txt", "w") as fo: | |
fo.write('0') | |
sys.exit(0) | |
b.sort() | |
l.sort() | |
d.sort() | |
j = 0 | |
paths = [] | |
for i in range(0, n): | |
while j < m - 1 and abs(b[i] - l[j]) > abs(b[i] - l[j + 1]): | |
j += 1 | |
x = abs(b[i] - l[j]) | |
paths.append(math.sqrt(x ** 2 + 1000 ** 2)) | |
paths.sort() | |
k = 0 | |
j = 0 | |
for i in range(0, n): | |
while j < s and paths[i] > d[j]: | |
j += 1 | |
if j < s: | |
k += 1 | |
j += 1 | |
else: | |
break | |
with open("output.txt", "w") as fo: | |
fo.write(str(k)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment