提出 #67963013


ソースコード 拡げる

#include <bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops,fast-math")
//#pragma GCC target("avx2,fma")
using namespace std;
typedef long long ll;
#define int ll
int tc,n,m;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    for(cin >> tc;tc;tc--) {
        cin >> n >> m;
        vector<int> a,b;
        ll ans=0; int z=0;
        a.resize(n); b.resize(n+1);
        for(int i=0;i<n;i++) cin >> a[i];
        for(int i=0;i<n;i++) cin >> b[i];
        for(int i=0;i<n;i++) ans+=a[i]+b[i];
        b[n]=m+1;
        sort(a.begin(),a.end());
        sort(b.begin(),b.end());
        for(int i=n-1;i>-1;i--) {
            int t=lower_bound(b.begin(),b.end(),m-a[i])-b.begin();
            if(t==n) break;
            else {
                b[t]=0;
                z++;
            }
        }
        cout << ans-z*m << "\n";
    }
}

提出情報

提出日時
問題 D - Match, Mod, Minimize 2
ユーザ Hakuaa_2
言語 C++ 20 (gcc 12.2)
得点 400
コード長 886 Byte
結果 AC
実行時間 86 ms
メモリ 7988 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 400 / 400
結果
AC × 1
AC × 30
セット名 テストケース
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
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 1 ms 3512 KiB
01_handmade_00.txt AC 81 ms 7988 KiB
01_handmade_01.txt AC 35 ms 7828 KiB
01_handmade_02.txt AC 50 ms 7872 KiB
01_handmade_03.txt AC 83 ms 7888 KiB
01_handmade_04.txt AC 1 ms 3540 KiB
01_handmade_05.txt AC 24 ms 3620 KiB
02_random_00.txt AC 84 ms 7820 KiB
02_random_01.txt AC 85 ms 7764 KiB
02_random_02.txt AC 86 ms 7900 KiB
02_random_03.txt AC 83 ms 7820 KiB
02_random_04.txt AC 49 ms 3568 KiB
02_random_05.txt AC 49 ms 3584 KiB
02_random_06.txt AC 49 ms 3480 KiB
02_random_07.txt AC 49 ms 3512 KiB
02_random_08.txt AC 49 ms 3656 KiB
02_random_09.txt AC 49 ms 3592 KiB
02_random_10.txt AC 70 ms 3740 KiB
02_random_11.txt AC 69 ms 3612 KiB
02_random_12.txt AC 69 ms 3540 KiB
02_random_13.txt AC 69 ms 3568 KiB
02_random_14.txt AC 69 ms 3604 KiB
02_random_15.txt AC 69 ms 3596 KiB
02_random_16.txt AC 56 ms 3484 KiB
02_random_17.txt AC 50 ms 3548 KiB
02_random_18.txt AC 50 ms 3464 KiB
02_random_19.txt AC 49 ms 3472 KiB
02_random_20.txt AC 49 ms 3476 KiB
02_random_21.txt AC 49 ms 3548 KiB
02_random_22.txt AC 49 ms 3628 KiB