欢乐赛T1,T2,T3,T4,T5题解
2025-10-20 10:49:03
发布于:江苏
T1
t, x, y, z = map(int, input().split())
file_size_mb = (x * y // 8 * z * t) / (1024 * 1024)
print("{0:.4f}".format(file_size_mb))
T2
n = int(input())
a = list(map(int, input().split()))
x, y = map(int, input().split())
wait_time = sum(a[x-1 : y-1])
print(wait_time)
T3
n = int(input())
s = input()
for student_id in range(1, n + 1):
st = input()
errors = []
max_len = max(len(s), len(st))
for pos in range(1, max_len + 1):
idx = pos - 1
if idx >= len(st):
errors.append(str(pos))
elif idx >= len(s):
errors.append(str(pos))
elif st[idx] != s[idx]:
errors.append(str(pos))
if errors:
print(f"{student_id} {' '.join(errors)}")
T4
def is_possible(k, n, m, t, x, y):
bomb_events = []
T_bomb = ((t + 11) // 12) * 12
bomb_time = 12
while bomb_time <= T_bomb:
bomb_events.append(bomb_time)
bomb_time += 12
repair_events = []
T_repair = ((t + 9) // 10) * 10
repair_time = 10
while repair_time <= T_repair:
repair_events.append(repair_time)
repair_time += 10
events = []
for t_b in bomb_events:
events.append((t_b, 'bomb'))
for t_r in repair_events:
events.append((t_r, 'repair'))
events.sort(key=lambda x: (x[0], 0 if x[1] == 'bomb' else 1))
current_armor = m
for time, typ in events:
if typ == 'bomb':
damage = 4 * n * x
current_armor -= damage
if current_armor <= 0:
return False
else:
repair = k * y
current_armor = min(current_armor + repair, m)
return current_armor > 0
def main():
n, m, t = map(int, input().split())
x, y = map(int, input().split())
if y == 0:
T_bomb = ((t + 11) // 12) * 12
num_bombs = T_bomb // 12
total_damage = num_bombs * 4 * n * x
if total_damage < m:
print(0)
else:
print(-1)
return
low = 0
high = 10**18
answer = -1
while low <= high:
mid = (low + high) // 2
if is_possible(mid, n, m, t, x, y):
answer = mid
high = mid - 1
else:
low = mid + 1
print(answer if answer != -1 else -1)
if __name__ == "__main__":
main()
T5
n, m = map(int, input().split())
students = {}
for _ in range(m):
x, y, a, b, c = map(int, input().split())
if y not in students:
students[y] = [0, 0, 0]
students[y][0] += a
students[y][1] += b
students[y][2] += c
result = []
for y in students:
a_total, b_total, c_total = students[y]
total = (a_total * 4 + b_total * 4 + c_total * 2) / 10.0
result.append((-total, y))
result.sort()
for item in result:
total = -item[0]
if total.is_integer():
print(f"{item[1]} {int(total)}")
else:
print(f"{item[1]} {total}")
这里空空如也
有帮助,赞一个