結果

問題 No.728 ギブ and テイク
ユーザー 👑 hos.lyrichos.lyric
提出日時 2019-01-27 09:08:32
言語 cLay
(20240104-1)
結果
AC  
実行時間 182 ms / 3,000 ms
コード長 457 bytes
コンパイル時間 5,270 ms
コンパイル使用メモリ 215,672 KB
実行使用メモリ 41,044 KB
最終ジャッジ日時 2023-09-19 00:19:38
合計ジャッジ時間 8,400 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
11,548 KB
testcase_01 AC 3 ms
11,624 KB
testcase_02 AC 3 ms
11,592 KB
testcase_03 AC 3 ms
11,640 KB
testcase_04 AC 4 ms
11,628 KB
testcase_05 AC 3 ms
11,544 KB
testcase_06 AC 3 ms
11,644 KB
testcase_07 AC 3 ms
11,624 KB
testcase_08 AC 3 ms
11,620 KB
testcase_09 AC 3 ms
11,552 KB
testcase_10 AC 4 ms
11,600 KB
testcase_11 AC 3 ms
11,600 KB
testcase_12 AC 4 ms
11,604 KB
testcase_13 AC 9 ms
14,180 KB
testcase_14 AC 14 ms
16,692 KB
testcase_15 AC 7 ms
14,072 KB
testcase_16 AC 12 ms
14,568 KB
testcase_17 AC 11 ms
14,340 KB
testcase_18 AC 114 ms
33,504 KB
testcase_19 AC 128 ms
33,768 KB
testcase_20 AC 151 ms
36,340 KB
testcase_21 AC 131 ms
33,896 KB
testcase_22 AC 46 ms
23,040 KB
testcase_23 AC 29 ms
17,840 KB
testcase_24 AC 93 ms
28,816 KB
testcase_25 AC 97 ms
28,964 KB
testcase_26 AC 46 ms
22,992 KB
testcase_27 AC 182 ms
41,044 KB
testcase_28 AC 61 ms
30,736 KB
testcase_29 AC 3 ms
11,620 KB
testcase_30 AC 3 ms
11,688 KB
testcase_31 AC 3 ms
11,544 KB
testcase_32 AC 4 ms
11,624 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(2N,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