/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 41ms 17.902 MiB
#2 Accepted 42ms 17.938 MiB
#3 Accepted 41ms 17.996 MiB
#4 Accepted 43ms 18.02 MiB
#5 Accepted 76ms 19.426 MiB
#6 Accepted 73ms 19.367 MiB
#7 Accepted 111ms 39.352 MiB
#8 Accepted 124ms 41.797 MiB
#9 Accepted 126ms 41.949 MiB
#10 Accepted 133ms 43.02 MiB
#11 Wrong Answer 92ms 20.461 MiB
#12 Wrong Answer 110ms 19.992 MiB

Code

import sys
from itertools import *
from bisect import *
from collections import *
from math import gcd
import heapq

input = lambda: sys.stdin.readline().rstrip("\r\n")
rint = lambda: int(input())
rlist = lambda: list(map(int, input().split()))
rgrid = lambda n: [rlist() for _ in range(n)]

fmin = lambda x, y: x if x < y else y
fmax = lambda x, y: x if x > y else y
# MOD = 998244353
MOD = 10**9 + 7
INF = float("inf")


def solve():
    N = rint()
    A = rlist()
    A.sort(reverse=True)
    P = [0] * (N + 1)
    for i, x in enumerate(A):
        P[i + 1] = P[i] + (-x if i & 1 else x)

    v = P[N]
    for k in range(N - 1, -1, -1):
        if k & 1:
            v = fmin(P[k], v)
        else:
            v = fmax(P[k], v)
    return v


TT = 1
TT = rint()
for tc in range(TT):
    ans = solve()

    print(ans)
    # print(*ans)
    # print("Yes" if ans else "No")

Information

Submit By
Type
Submission
Problem
P1208 C. Game on Integer
Contest
Educational Round 1
Language
PyPy 3 (Python 3.9.18 PyPy 7.3.15)
Submit At
2025-07-14 15:53:58
Judged At
2025-07-14 15:53:58
Judged By
Score
60
Total Time
133ms
Peak Memory
43.02 MiB