Submission #67925049


Source Code Expand

#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
namespace mlp = boost::multiprecision;
using bint = mlp::cpp_int;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using mint = modint998244353;
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define rep1(i,n) for (int i=1;i<(int)(n);i++)
#define rrep(i,n) for (ll i=n-1;i>=0;i--)
#define rrep1(i,n) for (ll i=n-1;i>0;i--)
#define chmax(a,b) a=max(a,b)
#define chmin(a,b) a=min(a,b)
#define pi 3.141592653589793238L

//対オーバーフロー兵器
//#define int long long

signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int T; cin>>T;
  rep(w,T){
    ll N,M; cin>>N>>M;
    vector<ll> A(N),B(N);
    rep(i,N) cin>>A[i];
    rep(i,N) cin>>B[i];
    sort(A.begin(),A.end());

    ll ans=0;
    rep(i,N) {ans+=A[i]; ans+=B[i];}

    multiset<ll> st;
    rep(i,N) st.insert(B[i]);
    st.insert(1e+18);

    rep(i,N){
      auto itr=st.lower_bound(M-A[i]);
      if (*itr==1e+18) continue;
      st.erase(st.find(*itr));
      ans-=M;
    }
    cout<<ans<<endl;

  }


  

  return 0;
}

Submission Info

Submission Time
Task D - Match, Mod, Minimize 2
User Fkun
Language C++ 20 (gcc 12.2)
Score 400
Code Size 1282 Byte
Status AC
Exec Time 164 ms
Memory 21924 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 3452 KiB
01_handmade_00.txt AC 125 ms 21788 KiB
01_handmade_01.txt AC 125 ms 21860 KiB
01_handmade_02.txt AC 100 ms 21764 KiB
01_handmade_03.txt AC 127 ms 21828 KiB
01_handmade_04.txt AC 1 ms 3572 KiB
01_handmade_05.txt AC 122 ms 3468 KiB
02_random_00.txt AC 149 ms 21840 KiB
02_random_01.txt AC 149 ms 21924 KiB
02_random_02.txt AC 148 ms 21860 KiB
02_random_03.txt AC 149 ms 21832 KiB
02_random_04.txt AC 77 ms 3492 KiB
02_random_05.txt AC 76 ms 3484 KiB
02_random_06.txt AC 77 ms 3536 KiB
02_random_07.txt AC 77 ms 3476 KiB
02_random_08.txt AC 77 ms 3572 KiB
02_random_09.txt AC 77 ms 3512 KiB
02_random_10.txt AC 99 ms 4160 KiB
02_random_11.txt AC 99 ms 4020 KiB
02_random_12.txt AC 100 ms 4196 KiB
02_random_13.txt AC 99 ms 4112 KiB
02_random_14.txt AC 98 ms 4192 KiB
02_random_15.txt AC 98 ms 4036 KiB
02_random_16.txt AC 164 ms 3532 KiB
02_random_17.txt AC 107 ms 3576 KiB
02_random_18.txt AC 107 ms 3472 KiB
02_random_19.txt AC 107 ms 3448 KiB
02_random_20.txt AC 107 ms 3532 KiB
02_random_21.txt AC 107 ms 3472 KiB
02_random_22.txt AC 107 ms 3524 KiB