結果
問題 | No.615 集合に分けよう |
ユーザー | buey_t |
提出日時 | 2023-03-31 09:56:33 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,181 bytes |
コンパイル時間 | 208 ms |
コンパイル使用メモリ | 82,392 KB |
実行使用メモリ | 161,024 KB |
最終ジャッジ日時 | 2024-09-22 15:23:36 |
合計ジャッジ時間 | 18,322 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 152 ms
90,136 KB |
testcase_01 | AC | 152 ms
90,028 KB |
testcase_02 | AC | 146 ms
89,952 KB |
testcase_03 | AC | 145 ms
89,960 KB |
testcase_04 | AC | 149 ms
89,988 KB |
testcase_05 | AC | 152 ms
90,108 KB |
testcase_06 | WA | - |
testcase_07 | AC | 149 ms
90,044 KB |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | AC | 156 ms
90,052 KB |
testcase_11 | AC | 155 ms
90,096 KB |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | AC | 228 ms
92,268 KB |
testcase_16 | TLE | - |
testcase_17 | AC | 718 ms
161,024 KB |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | TLE | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | AC | 137 ms
89,356 KB |
testcase_26 | AC | 137 ms
89,516 KB |
testcase_27 | AC | 719 ms
158,856 KB |
testcase_28 | AC | 724 ms
158,724 KB |
testcase_29 | AC | 778 ms
160,100 KB |
testcase_30 | WA | - |
ソースコード
def main(): from math import sqrt,sin,cos,tan,ceil,radians,floor,gcd,exp,log,log10,log2,factorial,fsum from heapq import heapify, heappop, heappush from bisect import bisect_left, bisect_right from copy import deepcopy import copy import random from collections import deque,Counter,defaultdict from itertools import permutations,combinations from decimal import Decimal,ROUND_HALF_UP #tmp = Decimal(mid).quantize(Decimal('0'), rounding=ROUND_HALF_UP) from functools import lru_cache, reduce #@lru_cache(maxsize=None) from operator import add,sub,mul,xor,and_,or_,itemgetter INF = 10**18 mod1 = 10**9+7 mod2 = 998244353 #DecimalならPython #再帰ならPython!!!!!!!!!!!!!!!!!!!!!!!!!! ''' ''' N,K = map(int, input().split()) A = list(map(int, input().split())) A.sort() h = INF l = -1 while h-l > 1: m = (h+l)//2 mx = -INF mi = INF cnt = 0 for i in range(N): mx = max(A[i],mx) mi = min(A[i],mi) if mx-mi > m: cnt += 1 mx = A[i] mi = A[i] cnt += 1 if cnt > K: l = m else: h = m ans = INF for k in range(l,l+500): if k < 0: continue mx = -INF mi = INF cnt = 0 tmp = 0 ls = [] for i in range(N): mx = max(A[i],mx) mi = min(A[i],mi) if mx-mi > k: cnt += 1 tmp += max(ls)-min(ls) mx = A[i] mi = A[i] ls = [] ls.append(A[i]) tmp += max(ls)-min(ls) cnt += 1 if cnt == K: ans = min(ans,tmp) print(ans) if __name__ == '__main__': main()