这是 2026-10-23 的上一版评测(LiveCodeBench 最新 35 题)。最新的阶梯评测见 首页。
结果
Kimi K3.1 ProKimi
✓
通过
- 官方测试 6/6判题
- 43.4k输出 token(含思考) ↓
- 735 秒延迟 ↓
- 0.16 秒(最快)最慢测试的 CPU 时间 ↓
- 32 MB峰值内存 ↓
- 7Pylint 问题 ↓
- 9.19Pylint 得分 ↑
- 36圈复杂度 ↓
- 51.6可维护性指数 ↑
- 90有效行
- 1SonarQube 问题 ↓
DeepSeek-V4.1-FlashDS-Flash
✓
通过
- 官方测试 6/6判题
- 55.0k输出 token(含思考) ↓
- 334 秒延迟 ↓
- 0.27 秒最慢测试的 CPU 时间 ↓
- 40 MB峰值内存 ↓
- 24Pylint 问题 ↓
- 8.56Pylint 得分 ↑
- 68圈复杂度 ↓
- 33.9可维护性指数 ↑
- 172有效行
- 3SonarQube 问题 ↓
DeepSeek-V4-ProDS-Pro
✓
通过
- 官方测试 6/6判题
- 112.7k输出 token(含思考) ↓
- 941 秒延迟 ↓
- 1.45 秒(9.3×)最慢测试的 CPU 时间 ↓
- 40 MB峰值内存 ↓
- 54Pylint 问题 ↓
- 6.82Pylint 得分 ↑
- 24圈复杂度 ↓
- 25.5可维护性指数 ↑
- 170有效行
- 3SonarQube 问题 ↓
↑ 越大越好,↓ 越小越好,有效行只描述代码长短。CPU 时间与内存只统计能区分性能的题(最慢答案扣除进程启动后仍 ≥ 0.1 秒),括号内为相对最快者的倍数(≥ 2 时标出)。静态质量按 arXiv:2610.19167 的口径(见 原理)。判题方法见 原理 › 判题。
代码
Kimi K3.1 Pro · 119 行
import sys def solve(): it = iter(map(int, sys.stdin.buffer.read().split())) test_count = next(it) answers = [] INF = 10 ** 30 for _ in range(test_count): n = next(it) k = next(it) values = [] maximum = [] base_color = [] for _ in range(n): x = next(it) y = next(it) z = next(it) values.append((x, y, z)) if x >= y and x >= z: maximum.append(x) base_color.append(0) elif y >= z: maximum.append(y) base_color.append(1) else: maximum.append(z) base_color.append(2) order = sorted(range(n), key=maximum.__getitem__, reverse=True) chosen_count = 2 * k chosen = order[:chosen_count] unchosen = order[chosen_count:] upper_bound = sum(maximum[i] for i in chosen) counts = [0, 0, 0] for i in chosen: counts[base_color[i]] += 1 odd_colors = [c for c in range(3) if counts[c] & 1] if not odd_colors: answers.append(str(upper_bound)) continue # Keep the two best candidates. Two changes can conflict on at most # one chosen cake and at most one unchosen cake. def add_two(lst, item): if len(lst) < 2: lst.append(item) lst.sort() elif item < lst[1]: lst[1] = item lst.sort() # recolor[a][b]: (loss, cake), for chosen cakes whose base color is a. recolor = [[[] for _ in range(3)] for _ in range(3)] # lowest[a]: two smallest maximum values among chosen cakes of color a. lowest = [[] for _ in range(3)] # highest[b]: two largest b-values among unchosen cakes, negated. highest = [[] for _ in range(3)] for i in chosen: a = base_color[i] mi = maximum[i] add_two(lowest[a], (mi, i)) for b in range(3): if a != b: add_two(recolor[a][b], (mi - values[i][b], i)) for j in unchosen: for b in range(3): add_two(highest[b], (-values[j][b], j)) # A change is (loss, chosen_cake, unchosen_cake). # unchosen_cake == -1 means a recoloring; otherwise it is a swap. changes = {} for a in range(3): for b in range(3): if a == b: continue current = [(loss, i, -1) for loss, i in recolor[a][b]] for mi, i in lowest[a]: for neg_value, j in highest[b]: current.append((mi + neg_value, i, j)) changes[(a, b)] = current a, b = odd_colors c = 3 - a - b best_loss = INF # One change toggling the two odd colors. for direction in ((a, b), (b, a)): for loss, _, _ in changes[direction]: best_loss = min(best_loss, loss) # Or two changes whose combined parity effect is the same. for d1 in ((a, c), (c, a)): for d2 in ((b, c), (c, b)): for first in changes[d1]: for second in changes[d2]: if first[1] == second[1]: continue if (first[2] != -1 and second[2] != -1 and first[2] == second[2]): continue best_loss = min( best_loss, first[0] + second[0] ) answers.append(str(upper_bound - best_loss)) sys.stdout.write("\n".join(answers)) if __name__ == "__main__": solve()
DeepSeek-V4.1-Flash · 220 行
import sys import heapq def solve(): data = list(map(int, sys.stdin.buffer.read().split())) it = iter(data) T = next(it) outs = [] NEG = -10**30 C = 15 for _ in range(T): N = next(it) K = next(it) vals = [] m = [0] * N p = [0] * N for i in range(N): x = next(it) y = next(it) z = next(it) vals.append((x, y, z)) if x >= y and x >= z: m[i] = x p[i] = 0 elif y >= x and y >= z: m[i] = y p[i] = 1 else: m[i] = z p[i] = 2 M = 2 * K order = list(range(N)) order.sort(key=lambda i: m[i], reverse=True) base = order[:M] outside = order[M:] base_sum = sum(m[i] for i in base) base_parity = 0 for i in base: base_parity ^= (1 << p[i]) smax = min(6, M, N - M) # Base candidates base_sorted = sorted(base, key=lambda i: m[i]) rem_cands = set() for pl in range(3): cnt = 0 for i in base_sorted: if p[i] == pl: rem_cands.add(i) cnt += 1 if cnt == C: break for i in base_sorted[:C]: rem_cands.add(i) mod_cands = set() for c in range(3): for pl in range(3): gen = (i for i in base if p[i] == pl) cand = heapq.nsmallest( C, gen, key=lambda i, c=c: m[i] - vals[i][c] ) for i in cand: mod_cands.add(i) base_cands = list(rem_cands | mod_cands) # Outside candidates out_unmod_cands = set() for pl in range(3): gen = (i for i in outside if p[i] == pl) cand = heapq.nlargest(C, gen, key=lambda i: m[i]) for i in cand: out_unmod_cands.add(i) out_mod_cands = set() for c in range(3): cand = heapq.nlargest( C, outside, key=lambda i, c=c: vals[i][c] ) for i in cand: out_mod_cands.add(i) outside_cands = list(out_unmod_cands | out_mod_cands) # DP over base-side operations: # removals, modifications, parity base_dp = [[[NEG] * 8 for _ in range(3)] for _ in range(smax + 1)] base_dp[0][0][0] = 0 for i in base_cands: pi = p[i] mi = m[i] vi = vals[i] ndp = [[row[:] for row in base_dp[r]] for r in range(smax + 1)] # Remove this base item if smax >= 1: togg = 1 << pi for r in range(smax): for mod in range(3): row = base_dp[r][mod] target = ndp[r + 1][mod] for par in range(8): val = row[par] if val == NEG: continue npar = par ^ togg nv = val - mi if nv > target[npar]: target[npar] = nv # Modify this base item for c in range(3): if c == pi: continue togg = (1 << pi) ^ (1 << c) add = vi[c] - mi for r in range(smax + 1): for mod in range(2): row = base_dp[r][mod] target = ndp[r][mod + 1] for par in range(8): val = row[par] if val == NEG: continue npar = par ^ togg nv = val + add if nv > target[npar]: target[npar] = nv base_dp = ndp # DP over outside-side operations: # additions, modifications among additions, parity out_dp = [[[NEG] * 8 for _ in range(3)] for _ in range(smax + 1)] out_dp[0][0][0] = 0 for i in outside_cands: pi = p[i] mi = m[i] vi = vals[i] ndp = [[row[:] for row in out_dp[r]] for r in range(smax + 1)] # Add unmodified if smax >= 1: togg = 1 << pi for a in range(smax): for mod in range(3): row = out_dp[a][mod] target = ndp[a + 1][mod] for par in range(8): val = row[par] if val == NEG: continue npar = par ^ togg nv = val + mi if nv > target[npar]: target[npar] = nv # Add modified for c in range(3): if c == pi: continue togg = 1 << c add = vi[c] for a in range(smax): for mod in range(2): row = out_dp[a][mod] target = ndp[a + 1][mod + 1] for par in range(8): val = row[par] if val == NEG: continue npar = par ^ togg nv = val + add if nv > target[npar]: target[npar] = nv out_dp = ndp best_delta = NEG for r in range(smax + 1): for mod_base in range(3): for mod_out in range(3 - mod_base): for pb in range(8): valb = base_dp[r][mod_base][pb] if valb == NEG: continue need_po = base_parity ^ pb valo = out_dp[r][mod_out][need_po] if valo == NEG: continue total = valb + valo if total > best_delta: best_delta = total outs.append(str(base_sum + best_delta)) sys.stdout.write("\n".join(outs)) if __name__ == "__main__": solve()
DeepSeek-V4-Pro · 203 行
import sys from heapq import heappush, heappop def solve(): data = list(map(int, sys.stdin.buffer.read().split())) idx = 0 T = data[idx] idx += 1 out = [] for _ in range(T): N = data[idx] K = data[idx + 1] idx += 2 X = [0] * N Y = [0] * N Z = [0] * N M = [0] * N maxc = [0] * N for i in range(N): x = data[idx] y = data[idx + 1] z = data[idx + 2] idx += 3 X[i] = x Y[i] = y Z[i] = z m = x c = 0 if y > m: m = y c = 1 if z > m: m = z c = 2 M[i] = m maxc[i] = c order = sorted(range(N), key=lambda i: M[i], reverse=True) selected = [False] * N sel = order[:2 * K] for i in sel: selected[i] = True base = sum(M[i] for i in sel) cnt = [0, 0, 0] for i in sel: cnt[maxc[i]] += 1 if cnt[0] % 2 == 0 and cnt[1] % 2 == 0 and cnt[2] % 2 == 0: out.append(str(base)) continue odd = [i for i in range(3) if cnt[i] % 2 == 1] a, b = odd[0], odd[1] c3 = 3 - a - b unselected = [i for i in range(N) if not selected[i]] Mmin = min(M[i] for i in sel) S = N col = [N + 1, N + 2, N + 3] V = N + 4 g = [[] for _ in range(V)] to = [] cap = [] edge_cost = [] def add_edge(u, v, cst): g[u].append(len(to)) to.append(v) cap.append(1) edge_cost.append(cst) g[v].append(len(to)) to.append(u) cap.append(0) edge_cost.append(-cst) for i in sel: ci = maxc[i] add_edge(col[ci], i, M[i]) add_edge(i, S, 0) if ci != 0: add_edge(i, col[0], -X[i]) if ci != 1: add_edge(i, col[1], -Y[i]) if ci != 2: add_edge(i, col[2], -Z[i]) for j in unselected: add_edge(S, j, 0) add_edge(j, col[0], -X[j]) add_edge(j, col[1], -Y[j]) add_edge(j, col[2], -Z[j]) pot0 = [0] * V pot0[S] = Mmin for i in sel: pot0[i] = M[i] for j in unselected: pot0[j] = M[j] INF = 10**30 def min_cost_option(src_list, tgt_list): supply = {} for s, amt in src_list: supply[s] = supply.get(s, 0) + amt demand = {} for t, amt in tgt_list: demand[t] = demand.get(t, 0) + amt flow_needed = sum(demand.values()) pot = pot0[:] changed = [] total_cost = 0 for _ in range(flow_needed): dist = [INF] * V prev_node = [-1] * V prev_edge = [-1] * V heap = [] for s, amt in supply.items(): if amt > 0: dist[s] = -pot[s] heappush(heap, (dist[s], s)) while heap: d, u = heappop(heap) if d != dist[u]: continue for eid in g[u]: if cap[eid] > 0: v = to[eid] nd = d + edge_cost[eid] + pot[u] - pot[v] if nd < dist[v]: dist[v] = nd prev_node[v] = u prev_edge[v] = eid heappush(heap, (nd, v)) target = -1 best_cost = INF for t, amt in demand.items(): if amt > 0 and dist[t] < INF: cur = dist[t] + pot[t] if cur < best_cost: best_cost = cur target = t if target == -1: for eid, old in reversed(changed): cap[eid] = old return INF node = target path_cost = 0 while prev_edge[node] != -1: eid = prev_edge[node] rev = eid ^ 1 changed.append((eid, cap[eid])) changed.append((rev, cap[rev])) cap[eid] -= 1 cap[rev] += 1 path_cost += edge_cost[eid] node = prev_node[node] source = node if supply.get(source, 0) <= 0: for eid, old in reversed(changed): cap[eid] = old return INF supply[source] -= 1 demand[target] -= 1 total_cost += path_cost for v in range(V): if dist[v] < INF: pot[v] += dist[v] for eid, old in reversed(changed): cap[eid] = old return total_cost ca, cb, cc = col[a], col[b], col[c3] loss = INF loss = min(loss, min_cost_option([(ca, 1)], [(cb, 1)])) loss = min(loss, min_cost_option([(cb, 1)], [(ca, 1)])) loss = min(loss, min_cost_option([(ca, 1), (cb, 1)], [(cc, 2)])) loss = min(loss, min_cost_option([(cc, 2)], [(ca, 1), (cb, 1)])) out.append(str(base - loss)) sys.stdout.write("\n".join(out)) if __name__ == "__main__": solve()