Code
import heapq
def max_element_after_operations(n, k, arr):
arr = [str(x) for x in arr]
heapq.heapify(arr)
for _ in range(k):
a = heapq.heappop(arr)
b = heapq.heappop(arr)
heapq.heappush(arr, a + b)
return max(arr)
t = int(input())
for _ in range(t):
n, k = map(int, input().split())
arr = list(map(int, input().split()))
print(max_element_after_operations(n, k, arr))
Information
- Submit By
- Type
- Pretest
- Problem
- P1083 Number concatenation
- Language
- Python 3 (Python 3.12.3)
- Submit At
- 2024-08-16 16:08:46
- Judged At
- 2024-08-16 16:08:46
- Judged By
- Score
- 0
- Total Time
- 15ms
- Peak Memory
- 2.77 MiB