voidsolve() { maxn = -INF; // 多测注意还原 int n, k, x; cin >> n >> k >> x; for (int i = 1; i <= n; i ++) cin >> a[i]; sort(a + 1, a + 1 + n, greater<>()); // 从大到小排序 for (int i = 1; i <= n; i ++) pre[i] = pre[i - 1] + a[i]; // 预处理前缀和数组 for (int i = 0; i <= k; i ++) // i 指的是 Alice 要删除元素的个数 { int res = 0; res = pre[n] - 2 * pre[min(i + x, n)] + pre[i]; maxn = max(maxn, res); } cout << maxn << '\n'; }
signedmain() { // ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); int T; cin >> T; while (T --) solve(); return0; }