Submission #64560363


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
void solve() {
	int n, k;
	cin >> n >> k;
	priority_queue<tuple<int, int, int>> px, py, pz;
	vector<bool> v(n);
	for (int i = 0; i < n; ++i) {
		int x, y, z;
		cin >> x >> y >> z;
		px.emplace(x, -y-z, i);
		py.emplace(y, -x-z, i);
		pz.emplace(z, -x-y, i);
	}
	auto t2 = [&] (priority_queue<tuple<int,int,int>> & pq, bool drop) -> pair<ll,ll> {
		while (v[get<2>(pq.top())]) pq.pop();
		auto p1 = pq.top();
		pq.pop();
		while (v[get<2>(pq.top())]) pq.pop();
		auto p2 = pq.top();
		pq.pop();
		if (!drop) {
			pq.push(p1);
			pq.push(p2);
		} else {
			v[get<2>(p1)] = true;
			v[get<2>(p2)] = true;
		}
		return {get<0>(p1) + get<0>(p2), get<1>(p1) + get<1>(p2)};
	};
	ll ans = 0;
	while (k--) {
		auto ax = t2(px, false);
		auto ay = t2(py, false);
		auto az = t2(pz, false);
		if (ax >= ay && ax >= az) {
			ans += ax.first;
			t2(px, true);
		} else if (ay >= ax && ay >= az) {
			ans += ay.first;
			t2(py, true);
		} else {
			ans += az.first;
			t2(pz, true);
		}
	}
	cout << ans << '\n';
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int T;
	cin >> T;
	while (T--) solve();
}

Submission Info

Submission Time
Task G - Patisserie ABC 3
User pr3pony
Language C++ 17 (gcc 12.2)
Score 0
Code Size 1247 Byte
Status WA
Exec Time 83 ms
Memory 6848 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 625
Status
AC × 2
AC × 37
WA × 25
Set Name Test Cases
Sample example_00.txt, example_01.txt
All example_00.txt, example_01.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, hand_07.txt, hand_08.txt, hand_09.txt, hand_10.txt, hand_11.txt, hand_12.txt, hand_13.txt, hand_14.txt, hand_15.txt, hand_16.txt, hand_17.txt, hand_18.txt, hand_19.txt, multi_00.txt, multi_01.txt, multi_02.txt, multi_03.txt, multi_04.txt, multi_05.txt, multi_06.txt, multi_07.txt, multi_08.txt, multi_09.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, random_28.txt, random_29.txt
Case Name Status Exec Time Memory
example_00.txt AC 1 ms 3512 KiB
example_01.txt AC 1 ms 3476 KiB
hand_00.txt AC 53 ms 6724 KiB
hand_01.txt AC 49 ms 6788 KiB
hand_02.txt AC 53 ms 6684 KiB
hand_03.txt AC 51 ms 6668 KiB
hand_04.txt AC 52 ms 6724 KiB
hand_05.txt WA 53 ms 6756 KiB
hand_06.txt WA 51 ms 6724 KiB
hand_07.txt AC 49 ms 6728 KiB
hand_08.txt AC 50 ms 6620 KiB
hand_09.txt AC 53 ms 6784 KiB
hand_10.txt AC 50 ms 6792 KiB
hand_11.txt AC 69 ms 6756 KiB
hand_12.txt AC 74 ms 6620 KiB
hand_13.txt WA 83 ms 6660 KiB
hand_14.txt AC 1 ms 3556 KiB
hand_15.txt AC 1 ms 3504 KiB
hand_16.txt AC 45 ms 6708 KiB
hand_17.txt WA 45 ms 6760 KiB
hand_18.txt AC 44 ms 6688 KiB
hand_19.txt AC 46 ms 6724 KiB
multi_00.txt AC 6 ms 3508 KiB
multi_01.txt WA 6 ms 3420 KiB
multi_02.txt WA 6 ms 3436 KiB
multi_03.txt WA 5 ms 3480 KiB
multi_04.txt WA 5 ms 3516 KiB
multi_05.txt WA 6 ms 3372 KiB
multi_06.txt WA 6 ms 3376 KiB
multi_07.txt WA 6 ms 3404 KiB
multi_08.txt WA 25 ms 3496 KiB
multi_09.txt WA 25 ms 3520 KiB
random_00.txt AC 26 ms 6844 KiB
random_01.txt AC 48 ms 6788 KiB
random_02.txt AC 39 ms 6708 KiB
random_03.txt AC 23 ms 6756 KiB
random_04.txt AC 35 ms 6688 KiB
random_05.txt WA 57 ms 6780 KiB
random_06.txt WA 62 ms 6648 KiB
random_07.txt AC 59 ms 6776 KiB
random_08.txt AC 58 ms 6848 KiB
random_09.txt WA 31 ms 6796 KiB
random_10.txt AC 26 ms 6708 KiB
random_11.txt WA 62 ms 6696 KiB
random_12.txt AC 30 ms 6656 KiB
random_13.txt AC 27 ms 6716 KiB
random_14.txt WA 60 ms 6780 KiB
random_15.txt AC 32 ms 6752 KiB
random_16.txt AC 49 ms 6676 KiB
random_17.txt WA 51 ms 6756 KiB
random_18.txt WA 37 ms 6668 KiB
random_19.txt WA 56 ms 6732 KiB
random_20.txt AC 57 ms 6728 KiB
random_21.txt WA 56 ms 6756 KiB
random_22.txt AC 61 ms 6620 KiB
random_23.txt AC 36 ms 6616 KiB
random_24.txt WA 46 ms 6780 KiB
random_25.txt AC 44 ms 6688 KiB
random_26.txt AC 29 ms 6712 KiB
random_27.txt WA 41 ms 6672 KiB
random_28.txt AC 52 ms 6756 KiB
random_29.txt WA 72 ms 6728 KiB