这是 2026-10-23 的上一版评测(LiveCodeBench 最新 35 题)。最新的阶梯评测见 首页。

题目 › arc196_a

Adjacent Delete

AtCoder ARC 196 A 题 · 2025-04-06 · 困难

反复删除两个相邻的数并得到二者之差的绝对值,直到长度不超过 1;求总得分最大值。

查看原题

结果

Kimi K3.1 ProKimi

✓

通过

  • 官方测试 43/43判题
  • 33.4k输出 token(含思考) ↓
  • 536 秒延迟 ↓
  • —最慢测试的 CPU 时间 ↓
  • —峰值内存 ↓
  • 3Pylint 问题 ↓
  • 9.36Pylint 得分 ↑
  • 10圈复杂度 ↓
  • 59.0可维护性指数 ↑
  • 48有效行
  • 0SonarQube 问题 ↓

DeepSeek-V4.1-FlashDS-Flash

✓

通过

  • 官方测试 43/43判题
  • 18.3k输出 token(含思考) ↓
  • 98 秒延迟 ↓
  • —最慢测试的 CPU 时间 ↓
  • —峰值内存 ↓
  • 6Pylint 问题 ↓
  • 9.18Pylint 得分 ↑
  • 21圈复杂度 ↓
  • 35.9可维护性指数 ↑
  • 73有效行
  • 0SonarQube 问题 ↓

DeepSeek-V4-ProDS-Pro

✓

通过

  • 官方测试 43/43判题
  • 48.3k输出 token(含思考) ↓
  • 351 秒延迟 ↓
  • —最慢测试的 CPU 时间 ↓
  • —峰值内存 ↓
  • 7Pylint 问题 ↓
  • 8.54Pylint 得分 ↑
  • 12圈复杂度 ↓
  • 56.3可维护性指数 ↑
  • 50有效行
  • 0SonarQube 问题 ↓

↑ 越大越好,↓ 越小越好,有效行只描述代码长短。CPU 时间与内存只统计能区分性能的题(最慢答案扣除进程启动后仍 ≥ 0.1 秒),括号内为相对最快者的倍数(≥ 2 时标出)。静态质量按 arXiv:2610.19167 的口径(见 原理)。判题方法见 原理 › 判题。

代码

Kimi K3.1 Pro · 66 行
import sys
import heapq


def prefix_scores(a):
    """res[2*t] = (sum of t largest) - (sum of t smallest) in each prefix."""
    n = len(a)
    res = [0] * (n + 1)

    low = []   # max-heap (stored negated): smaller half
    high = []  # min-heap: larger half
    sum_low = 0
    sum_high = 0

    for i, x in enumerate(a, 1):
        if not low or x <= -low[0]:
            heapq.heappush(low, -x)
            sum_low += x
        else:
            heapq.heappush(high, x)
            sum_high += x

        if len(low) > len(high) + 1:
            y = -heapq.heappop(low)
            sum_low -= y
            heapq.heappush(high, y)
            sum_high += y
        elif len(low) < len(high):
            y = heapq.heappop(high)
            sum_high -= y
            heapq.heappush(low, -y)
            sum_low += y

        if i % 2 == 0:
            res[i] = sum_high - sum_low

    return res


def main():
    data = list(map(int, sys.stdin.buffer.read().split()))
    n = data[0]
    a = data[1:]

    if n % 2 == 0:
        b = sorted(a)
        m = n // 2
        answer = sum(b[m:]) - sum(b[:m])
        print(answer)
        return

    # If the final remaining element is a[left] (0-based), left is even.
    # The elements before and after it must be removed independently.
    pref = prefix_scores(a)
    suff = prefix_scores(a[::-1])

    answer = 0
    for left in range(0, n, 2):
        right_len = n - 1 - left
        answer = max(answer, pref[left] + suff[right_len])

    print(answer)


if __name__ == "__main__":
    main()