結果
問題 |
No.3165 [Cherry 7th Tune A] Croissants Continu
|
ユーザー |
|
提出日時 | 2025-05-30 21:30:25 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 244 ms / 2,000 ms |
コード長 | 1,798 bytes |
コンパイル時間 | 366 ms |
コンパイル使用メモリ | 82,360 KB |
実行使用メモリ | 136,468 KB |
最終ジャッジ日時 | 2025-05-30 21:30:42 |
合計ジャッジ時間 | 7,709 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 31 |
ソースコード
import collections,sys,math,functools,operator,itertools,bisect,heapq,decimal,string,time,random #sys.setrecursionlimit(10**9) #sys.set_int_max_str_digits(0) input = sys.stdin.readline #n = int(input()) #a = list(map(int,input().split())) #a = [] #s = input() #n,m = map(int,input().split()) #for i in range(n): # a.append(list(map(int,input().split()))) class UnionFind(): def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.parents[x]) return self.parents[x] def union(self, x, y): x = self.find(x) y = self.find(y) if x == y: return if self.parents[x] > self.parents[y]: x, y = y, x self.parents[x] += self.parents[y] self.parents[y] = x def size(self, x): return -self.parents[self.find(x)] def same(self, x, y): return self.find(x) == self.find(y) def members(self, x): root = self.find(x) return [i for i in range(self.n) if self.find(i) == root] def roots(self): return [i for i, x in enumerate(self.parents) if x < 0] def group_count(self): return len(self.roots()) def all_group_members(self): group_members = collections.defaultdict(list) for member in range(self.n): group_members[self.find(member)].append(member) return group_members def __str__(self): return ''.join(f'{r}: {m}' for r, m in self.all_group_members().items()) t = int(input()) for i in range(t): n = int(input()) a = list(map(int,input().split())) x = max(a) s = sum(a) y = s - x z = min(x,y+1) print(y + z)