Решение олимпиадных задач по информатике: Антон и арбузы
Сегодня решаем олимпиадную задачу по информатике школьного этапа 2022 года. Задача: "Антон и арбузы". 9 - 11 класс.
n, m, d = int(input()), int(input()), int(input()) field = [] for _ in range(n): field.append([0] * m) for _ in range(d): xi, yi = int(input()), int(input()) for x in range(xi): for y in range(yi): field[x][y] += 1 largest = 0 for row in field: for elem in row: if elem > largest: largest = elem count = 0 for row in field: for elem in row: if elem == largest: count += 1 print(count, largest)
n, m, d = int(input()), int(input()), int(input()) field = [[0] * m for _ in range(n)] for _ in range(d): xi, yi = int(input()), int(input()) for x in range(xi): for y in range(yi): field[x][y] += 1 largest = max([max(row) for row in field]) count = sum([row.count(largest) for row in field]) print(count, largest)
var x,y,xi,yi,i,n,m,d,count,largest:integer; field:array[,] of integer; begin read(n); read(m); read(d); field := new integer[n, m]; for i := 1 to d do begin read(xi); read(yi); for x := 0 to xi - 1 do for y := 0 to yi - 1 do field[x, y] := field[x, y] + 1 end; largest := 0; for x := 0 to n - 1 do for y := 0 to m - 1 do if field[x, y] > largest then largest := field[x, y]; count := 0; for x := 0 to n - 1 do for y := 0 to m - 1 do if field[x, y] = largest then count := count + 1; write(count, ' ', largest); end.