problem AOR Ika-chan is taking a class where grades are determined only by the score of…
- User
problem
AOR Ika-chan is taking a class where grades are determined only by the score of the report. AOR Ika-chan has friends who are taking the same class, and if you have a report on a theme that you are not good at, you can get the same score as that friend by copying the report of a friend who is good at that theme. .. However, the teacher should not be aware that you are copying someone else's report, so you have to finish the report yourself, not copying someone else's report at least out of times. Also, AOR Ika didn't want to bother her friends, so she decided to copy the report to her friend less than times. Answer the maximum total score that AOR Ika can get when given the score when AOR Ika finishes the report by herself and the score when her friend finishes the report. input
Assistant
import sys from collections import defaultdict def main(): N, M, K = map(int, sys.stdin.readline().split()) a = list(map(int, sys.stdin.readline().split())) b = [] for _ in range(M): b.append(list(map(int, sys.stdin.readline().split()))) T = list(map(int, sys.stdin.readline().split())) best_deltas = [] for i in range(N): ai = a[i] best_d = 0 best_j = -1 for j in range(M): current_b = b[j][i] delta = current_b - ai if delta > best_d: best_d = delta best_j = j if best_d > 0 and best_j != -1: best_deltas.append( (best_d, best_j) ) friend_deltas = defaultdict(list) for d, j in best_deltas: friend_deltas[j].append(d) selected = [] for j in range(M): if j not in friend_deltas: continue lst = friend_deltas[j] lst.sort(reverse=True) take = min(T[j], len(lst)) selected.extend(lst[:take]) selected.sort(reverse=True) max_copies = N - K take = min(max_copies, len(selected)) sum_d = sum(selected[:take]) total = sum(a) + sum_d print(total) if __name__ == "__main__": main()
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.