結果

問題 No.728 ギブ and テイク
ユーザー 👑 hos.lyrichos.lyric
提出日時 2019-01-27 09:06:11
言語 cLay
(20240104-1)
結果
WA  
実行時間 -
コード長 456 bytes
コンパイル時間 5,432 ms
コンパイル使用メモリ 217,236 KB
実行使用メモリ 37,104 KB
最終ジャッジ日時 2023-09-19 00:19:57
合計ジャッジ時間 8,340 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
11,620 KB
testcase_01 WA -
testcase_02 AC 3 ms
11,620 KB
testcase_03 AC 3 ms
11,624 KB
testcase_04 AC 3 ms
11,772 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 64 ms
30,820 KB
testcase_29 AC 3 ms
11,536 KB
testcase_30 AC 3 ms
11,644 KB
testcase_31 AC 3 ms
11,596 KB
testcase_32 AC 3 ms
11,628 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

ll N,A[9d5],B[9d5],c[9d5],z,j,k;
{
  rd(N,A(N));
  rep(i,N)rd(B[i],B[i+N]);
  rep(i,2N)c[i]=i;
  sortA(N,B,c);
  fenwick<ll> l,r;
  l.malloc(N);
  r.malloc(N);
  l.init(N);
  r.init(N);
  rep(i,2N){
    j=c[i];
    if(j<N){
      k=lower_bound(A,A+N,A[j]-B[i])-A;
      z+=j-k-r.get(j-1)+r.get(k-1);
      l.add(j,1);
    }else{
      j-=N;
      k=upper_bound(A,A+N,A[j]+B[i])-A;
      z+=k-j-1-l.get(k-1)+l.get(j);
      r.add(j,1);
    }
  }
  wt(z);
}
0