Submission #67934063


Source Code Expand

#include <bits/stdc++.h>
using namespace std;

using ui = unsigned;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

template <typename T, typename... Args>
void dbg(const T &first, Args... args) {
	cout << first;
	if constexpr (sizeof...(args)) {
		cout.put(' ');
		dbg(args...);
	} else {
		cout << endl;
	}
}

constexpr int N = 300000 + 1;

int a[N], b[N];

void solve() {
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
	}
	for (int i = 1; i <= n; ++i) {
		cin >> b[i];
	}
	
	ll ans = accumulate(a + 1, a + n + 1, 0ll) + accumulate(b + 1, b + n + 1, 0ll);
	
	multiset<int> mst;
	for (int i = 1; i <= n; ++i) {
		mst.insert(a[i]);
	}
	for (int i = 1; i <= n; ++i) {
		auto itr = mst.lower_bound(m - b[i]);
		if (itr == mst.end()) {
			continue;
		}
		mst.erase(itr);
		ans -= m;
	}
	cout << ans << '\n';
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
#ifdef jiji
	freopen("../IO/input.txt", "r", stdin);
#endif
	
	int t;
	cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}

Submission Info

Submission Time
Task D - Match, Mod, Minimize 2
User SkyWave2022
Language C++ 23 (gcc 12.2)
Score 400
Code Size 1120 Byte
Status AC
Exec Time 190 ms
Memory 19964 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 1
AC × 30
Set Name Test Cases
Sample 00_sample_00.txt
All 00_sample_00.txt, 01_handmade_00.txt, 01_handmade_01.txt, 01_handmade_02.txt, 01_handmade_03.txt, 01_handmade_04.txt, 01_handmade_05.txt, 02_random_00.txt, 02_random_01.txt, 02_random_02.txt, 02_random_03.txt, 02_random_04.txt, 02_random_05.txt, 02_random_06.txt, 02_random_07.txt, 02_random_08.txt, 02_random_09.txt, 02_random_10.txt, 02_random_11.txt, 02_random_12.txt, 02_random_13.txt, 02_random_14.txt, 02_random_15.txt, 02_random_16.txt, 02_random_17.txt, 02_random_18.txt, 02_random_19.txt, 02_random_20.txt, 02_random_21.txt, 02_random_22.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3432 KiB
01_handmade_00.txt AC 180 ms 19832 KiB
01_handmade_01.txt AC 124 ms 19896 KiB
01_handmade_02.txt AC 92 ms 19908 KiB
01_handmade_03.txt AC 190 ms 19808 KiB
01_handmade_04.txt AC 1 ms 3488 KiB
01_handmade_05.txt AC 21 ms 3404 KiB
02_random_00.txt AC 183 ms 19804 KiB
02_random_01.txt AC 183 ms 19904 KiB
02_random_02.txt AC 183 ms 19964 KiB
02_random_03.txt AC 183 ms 19880 KiB
02_random_04.txt AC 63 ms 3516 KiB
02_random_05.txt AC 63 ms 3492 KiB
02_random_06.txt AC 63 ms 3500 KiB
02_random_07.txt AC 63 ms 3492 KiB
02_random_08.txt AC 63 ms 3520 KiB
02_random_09.txt AC 64 ms 3492 KiB
02_random_10.txt AC 90 ms 4044 KiB
02_random_11.txt AC 88 ms 3972 KiB
02_random_12.txt AC 90 ms 4056 KiB
02_random_13.txt AC 89 ms 4048 KiB
02_random_14.txt AC 89 ms 3964 KiB
02_random_15.txt AC 88 ms 4024 KiB
02_random_16.txt AC 58 ms 3500 KiB
02_random_17.txt AC 58 ms 3576 KiB
02_random_18.txt AC 58 ms 3368 KiB
02_random_19.txt AC 59 ms 3516 KiB
02_random_20.txt AC 59 ms 3636 KiB
02_random_21.txt AC 59 ms 3452 KiB
02_random_22.txt AC 59 ms 3436 KiB