結果

問題 No.1597 Matrix Sort
ユーザー MtSakaMtSaka
提出日時 2021-07-09 23:43:24
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,890 bytes
コンパイル時間 1,617 ms
コンパイル使用メモリ 170,644 KB
実行使用メモリ 4,748 KB
最終ジャッジ日時 2023-09-14 11:03:37
合計ジャッジ時間 8,963 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 WA -
testcase_04 AC 357 ms
4,604 KB
testcase_05 AC 362 ms
4,604 KB
testcase_06 AC 363 ms
4,616 KB
testcase_07 AC 369 ms
4,616 KB
testcase_08 AC 313 ms
4,744 KB
testcase_09 AC 314 ms
4,616 KB
testcase_10 AC 236 ms
4,552 KB
testcase_11 AC 198 ms
4,612 KB
testcase_12 AC 170 ms
4,696 KB
testcase_13 AC 285 ms
4,616 KB
testcase_14 AC 333 ms
4,708 KB
testcase_15 AC 142 ms
4,612 KB
testcase_16 AC 211 ms
4,608 KB
testcase_17 AC 241 ms
4,608 KB
testcase_18 AC 346 ms
4,616 KB
testcase_19 AC 270 ms
4,608 KB
testcase_20 AC 239 ms
4,748 KB
testcase_21 AC 233 ms
4,556 KB
testcase_22 AC 225 ms
4,604 KB
testcase_23 AC 219 ms
4,736 KB
testcase_24 AC 42 ms
4,612 KB
testcase_25 AC 40 ms
4,552 KB
testcase_26 WA -
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//GIVE ME AC!!!!!!!!!!!!!!!!!
//#pragma GCC target("avx")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define floatset() fixed<<setprecision(15)
#define all(n) n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
#define rep(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define pb push_back
#define eb emplace_back
#define max_(a) *max_element(all(a))
#define min_(a) *min_element(all(a))
#define INT(...) int __VA_ARGS__;scan(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;scan(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;scan(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;scan(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;scan(__VA_ARGS__)
#define LD(...) ld __VA_ARGS__;scan(__VA_ARGS__)
using namespace std;
using vl=vector<ll>;
using vi=vector<int>;
using vs=vector<string>;
using vc=vector<char>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using vvc=vector<vc>;
using vd=vector<double>;
using vp=vector<P>;
using vb=vector<bool>;
using P=pair<ll,ll>;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const ll inf =1e18;
const ll MOD=1000000007;
const ll mod=998244353;
const double pi=acos(-1);
template<typename T1,typename T2 >
ostream &operator<<(ostream&os,const pair<T1,T2>&p) {
  os<<p.first<<" "<<p.second;
  return os;
}
template<typename T1,typename T2>
istream &operator>>(istream&is,pair<T1,T2>&p) {
  is>>p.first>>p.second;
  return is;
}
template<typename T>
ostream &operator<<(ostream&os,const vector<T>&v) {
  for(int i=0;i<(int)v.size();i++) {
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  return os;
}
template<typename T>
istream &operator>>(istream&is,vector<T>&v) {
  for(T &in:v)is>>in;
  return is;
}
void scan(){}
template<class Head,class... Tail>
void scan(Head&head,Tail&... tail) {
  cin>>head;
  scan(tail...);
}
template<class T>
void print(const T &t) { cout << t << '\n'; }
template<class Head, class... Tail>
void print(const Head &head, const Tail &... tail) {
  cout << head << ' ';
  print(tail...);
}
template<class... T>
void fin(const T &... a) {
  print(a...);
  exit(0);
}
template<typename T>
ll sum_(vector<T>&v){
  ll res=0;
  for(auto &e:v)res+=e;
  return res;
}
template<typename T1,typename T2>
inline bool chmax(T1&a,T2 b){return a<b&&(a=b,true);}
template<typename T1,typename T2>
inline bool chmin(T1&a,T2 b){return a>b&&(a=b,true);}
int main(){
  LL(n,k,p);
  vl a(n),b(n);
  cin>>a>>b;
  sort(all(a));
  sort(all(b));
  ll l=0,r=p;
  while(r-l>1){
    ll mid=(l+r)/2;
    ll now=0;
    rep(i,0,n){
      ll cnt=0;
      cnt-=(lower_bound(all(b),0LL)-b.begin());
      cnt+=(lower_bound(all(b),mid-a[i]+1)-b.begin());
      cnt+=n-(lower_bound(all(b),p-a[i])-b.begin());
      cnt-=n-(lower_bound(all(b),1+p+mid-a[i])-b.begin());
      now+=cnt;
    }
    if(now<k)l=mid;
    else r=mid;
  }
  cout<<r<<endl;
}
0