結果
問題 | No.120 傾向と対策:門松列(その1) |
ユーザー | tonnnura172 |
提出日時 | 2020-05-07 09:47:20 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 174 ms / 5,000 ms |
コード長 | 1,097 bytes |
コンパイル時間 | 97 ms |
コンパイル使用メモリ | 10,856 KB |
実行使用メモリ | 9,852 KB |
最終ジャッジ日時 | 2023-09-16 07:46:09 |
合計ジャッジ時間 | 1,941 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 154 ms
9,852 KB |
testcase_01 | AC | 174 ms
9,664 KB |
testcase_02 | AC | 97 ms
9,704 KB |
testcase_03 | AC | 170 ms
9,676 KB |
ソースコード
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd, log from itertools import accumulate, permutations, combinations, product from operator import itemgetter, mul, add from copy import deepcopy from string import ascii_lowercase, ascii_uppercase, digits from bisect import bisect, bisect_left from heapq import heappush, heappop from functools import reduce, lru_cache def input(): return sys.stdin.readline().strip() def INT(): return int(input()) def MAP(): return map(int, input().split()) def LIST(): return list(map(int, input().split())) def ZIP(n): return zip(*(MAP() for _ in range(n))) sys.setrecursionlimit(10 ** 9) INF = float('inf') mod = 10 ** 9 + 7 T = INT() ans = [] for _ in range(T): N = INT() L = LIST() l = [] cnt = 0 for k, v in Counter(L).items(): heappush(l, (-v, k)) while len(l) >= 3: tmp = [] for _ in range(3): tmp.append(heappop(l)) for v, k in tmp: v *= -1 v -= 1 if v >= 1: heappush(l, (-v, k)) cnt += 1 ans.append(cnt) print(*ans, sep="\n")