結果
問題 | No.615 集合に分けよう |
ユーザー | buey_t |
提出日時 | 2023-03-31 09:55:37 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,181 bytes |
コンパイル時間 | 167 ms |
コンパイル使用メモリ | 82,384 KB |
実行使用メモリ | 148,508 KB |
最終ジャッジ日時 | 2024-09-22 15:22:37 |
合計ジャッジ時間 | 11,628 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 137 ms
89,472 KB |
testcase_01 | AC | 137 ms
89,452 KB |
testcase_02 | AC | 137 ms
89,488 KB |
testcase_03 | AC | 143 ms
89,500 KB |
testcase_04 | AC | 148 ms
89,956 KB |
testcase_05 | AC | 144 ms
89,936 KB |
testcase_06 | WA | - |
testcase_07 | AC | 145 ms
89,700 KB |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | AC | 148 ms
89,636 KB |
testcase_11 | AC | 153 ms
89,680 KB |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | AC | 182 ms
89,992 KB |
testcase_16 | AC | 1,163 ms
96,328 KB |
testcase_17 | AC | 405 ms
148,132 KB |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | AC | 1,168 ms
96,412 KB |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | AC | 135 ms
89,184 KB |
testcase_26 | AC | 136 ms
89,216 KB |
testcase_27 | AC | 396 ms
146,828 KB |
testcase_28 | AC | 392 ms
146,704 KB |
testcase_29 | AC | 478 ms
147,012 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+200): 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()