結果
問題 | No.1906 Twinkle Town |
ユーザー | donuthole |
提出日時 | 2022-12-24 15:44:02 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 345 ms / 2,000 ms |
コード長 | 1,835 bytes |
コンパイル時間 | 412 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 111,512 KB |
最終ジャッジ日時 | 2024-11-18 05:18:39 |
合計ジャッジ時間 | 19,739 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 156 ms
82,944 KB |
testcase_01 | AC | 152 ms
82,944 KB |
testcase_02 | AC | 156 ms
82,944 KB |
testcase_03 | AC | 334 ms
84,352 KB |
testcase_04 | AC | 319 ms
84,480 KB |
testcase_05 | AC | 343 ms
84,224 KB |
testcase_06 | AC | 319 ms
84,224 KB |
testcase_07 | AC | 345 ms
84,352 KB |
testcase_08 | AC | 345 ms
84,352 KB |
testcase_09 | AC | 340 ms
84,224 KB |
testcase_10 | AC | 329 ms
84,352 KB |
testcase_11 | AC | 332 ms
84,352 KB |
testcase_12 | AC | 329 ms
84,352 KB |
testcase_13 | AC | 343 ms
84,352 KB |
testcase_14 | AC | 338 ms
84,352 KB |
testcase_15 | AC | 342 ms
84,096 KB |
testcase_16 | AC | 315 ms
84,480 KB |
testcase_17 | AC | 329 ms
84,352 KB |
testcase_18 | AC | 323 ms
84,480 KB |
testcase_19 | AC | 326 ms
84,480 KB |
testcase_20 | AC | 324 ms
84,224 KB |
testcase_21 | AC | 306 ms
84,224 KB |
testcase_22 | AC | 275 ms
84,224 KB |
testcase_23 | AC | 308 ms
83,840 KB |
testcase_24 | AC | 274 ms
84,096 KB |
testcase_25 | AC | 310 ms
84,096 KB |
testcase_26 | AC | 281 ms
83,840 KB |
testcase_27 | AC | 304 ms
83,840 KB |
testcase_28 | AC | 280 ms
83,968 KB |
testcase_29 | AC | 319 ms
98,560 KB |
testcase_30 | AC | 312 ms
101,376 KB |
testcase_31 | AC | 325 ms
99,696 KB |
testcase_32 | AC | 294 ms
92,928 KB |
testcase_33 | AC | 320 ms
98,944 KB |
testcase_34 | AC | 300 ms
102,784 KB |
testcase_35 | AC | 327 ms
100,396 KB |
testcase_36 | AC | 295 ms
98,396 KB |
testcase_37 | AC | 332 ms
105,796 KB |
testcase_38 | AC | 297 ms
96,640 KB |
testcase_39 | AC | 340 ms
111,512 KB |
testcase_40 | AC | 339 ms
111,256 KB |
testcase_41 | AC | 337 ms
111,260 KB |
testcase_42 | AC | 338 ms
111,384 KB |
testcase_43 | AC | 336 ms
110,992 KB |
testcase_44 | AC | 343 ms
111,380 KB |
testcase_45 | AC | 282 ms
84,352 KB |
testcase_46 | AC | 318 ms
84,248 KB |
testcase_47 | AC | 313 ms
84,608 KB |
testcase_48 | AC | 303 ms
84,352 KB |
testcase_49 | AC | 283 ms
83,712 KB |
ソースコード
# region template from platform import node from typing import Generic, Iterable, Iterator, TypeVar, Union, List from bisect import bisect_left, bisect_right, insort from re import A import typing import math import sys import copy import itertools import collections import bisect import heapq import decimal def ni(): return int(sys.stdin.readline()) def ns(): return map(int, sys.stdin.readline().split()) def ns1(): return map(lambda x: int(x)-1, sys.stdin.readline().split()) def na(): return list(map(int, sys.stdin.readline().split())) def na1(): return list(map(lambda x: int(x)-1, sys.stdin.readline().split())) def nall_i(): return list(map(int, sys.stdin.read().split())) def nall_s(): return list(map(str, sys.stdin.read().split())) def flush(): return sys.stdout.flush() def nib(): return int(sys.stdin.buffer.readline()) def nsb(): return map(int, sys.stdin.buffer.readline().split()) def ns1b(): return map(lambda x: int(x)-1, sys.stdin.buffer.readline().split()) def nab(): return list(map(int, sys.stdin.buffer.readline().split())) def na1b(): return list(map(lambda x: int(x)-1, sys.stdin.buffer.readline().split())) def nallb(): return list(map(int, sys.stdin.buffer.read().split())) # limregion # sys.setrecursionlimit(10**7+1) inf = 10**23 # mod = 10**9+7 mod = 998244353 def main(): # https://open.spotify.com/track/6ldZaRUFcKh908SJXwdbZj?si=383824f68a8a47c0 def solve(): N = ni() A = na() A.sort() B = [A[0] if i == 0 else A[i]-A[i-1] for i in range(N)] hq = [] res = 0 for i, bi in enumerate(B): heapq.heappush(hq, -bi) if i % 2 == 0: res += -heapq.heappop(hq) print(res if N % 2 else A[-1]-res) T = ni() for _ in range(T): solve() if __name__ == '__main__': main()