Submission #67945018


Source Code Expand

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) { return (ull)rng() % B; }

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int q;
    cin >> q;
    while (q--) {
        int n, m;
        cin >> n >> m;
        vector<ll> a(n), b(n);
        ll sum = 0;
        for (int i = 0; i < n; ++i) {
            cin >> a[i];
            sum += a[i];
        }
        for (int i = 0; i < n; ++i) {
            cin >> b[i];
            sum += b[i];
        }
        sort(a.begin(), a.end());
        sort(b.rbegin(), b.rend());
        for (int i = 0, j = 0; i < n; ++i) {
            while (j < n and a[j] + b[i] < m) {
                j += 1;
            }
            if (j < n) {
                sum -= m;
                j += 1;
            }
        }
        cout << sum << '\n';
    }
}

Submission Info

Submission Time
Task D - Match, Mod, Minimize 2
User KKT89
Language C++ 20 (gcc 12.2)
Score 400
Code Size 1030 Byte
Status AC
Exec Time 73 ms
Memory 7936 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 3508 KiB
01_handmade_00.txt AC 69 ms 7852 KiB
01_handmade_01.txt AC 37 ms 7884 KiB
01_handmade_02.txt AC 38 ms 7876 KiB
01_handmade_03.txt AC 73 ms 7876 KiB
01_handmade_04.txt AC 1 ms 3504 KiB
01_handmade_05.txt AC 23 ms 3520 KiB
02_random_00.txt AC 72 ms 7852 KiB
02_random_01.txt AC 73 ms 7936 KiB
02_random_02.txt AC 72 ms 7852 KiB
02_random_03.txt AC 73 ms 7836 KiB
02_random_04.txt AC 47 ms 3556 KiB
02_random_05.txt AC 47 ms 3564 KiB
02_random_06.txt AC 47 ms 3476 KiB
02_random_07.txt AC 48 ms 3532 KiB
02_random_08.txt AC 47 ms 3512 KiB
02_random_09.txt AC 47 ms 3548 KiB
02_random_10.txt AC 58 ms 3628 KiB
02_random_11.txt AC 59 ms 3636 KiB
02_random_12.txt AC 59 ms 3644 KiB
02_random_13.txt AC 58 ms 3500 KiB
02_random_14.txt AC 58 ms 3640 KiB
02_random_15.txt AC 58 ms 3772 KiB
02_random_16.txt AC 57 ms 3488 KiB
02_random_17.txt AC 49 ms 3512 KiB
02_random_18.txt AC 49 ms 3504 KiB
02_random_19.txt AC 49 ms 3524 KiB
02_random_20.txt AC 49 ms 3568 KiB
02_random_21.txt AC 50 ms 3572 KiB
02_random_22.txt AC 49 ms 3576 KiB