結果

問題 No.1110 好きな歌
ユーザー 👑 NachiaNachia
提出日時 2020-10-24 18:55:51
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 364 ms / 5,000 ms
コード長 587 bytes
コンパイル時間 1,598 ms
コンパイル使用メモリ 168,908 KB
実行使用メモリ 5,732 KB
最終ジャッジ日時 2023-09-28 20:39:04
合計ジャッジ時間 15,942 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 3 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 3 ms
4,376 KB
testcase_20 AC 3 ms
4,376 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 3 ms
4,380 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 208 ms
4,744 KB
testcase_25 AC 252 ms
4,988 KB
testcase_26 AC 130 ms
4,380 KB
testcase_27 AC 253 ms
5,092 KB
testcase_28 AC 144 ms
4,380 KB
testcase_29 AC 287 ms
5,272 KB
testcase_30 AC 146 ms
4,376 KB
testcase_31 AC 91 ms
4,380 KB
testcase_32 AC 326 ms
5,596 KB
testcase_33 AC 168 ms
4,472 KB
testcase_34 AC 229 ms
4,956 KB
testcase_35 AC 352 ms
5,632 KB
testcase_36 AC 39 ms
4,376 KB
testcase_37 AC 100 ms
4,380 KB
testcase_38 AC 294 ms
5,488 KB
testcase_39 AC 219 ms
4,880 KB
testcase_40 AC 279 ms
5,308 KB
testcase_41 AC 22 ms
4,376 KB
testcase_42 AC 316 ms
5,484 KB
testcase_43 AC 285 ms
5,292 KB
testcase_44 AC 364 ms
5,696 KB
testcase_45 AC 358 ms
5,700 KB
testcase_46 AC 357 ms
5,732 KB
testcase_47 AC 355 ms
5,644 KB
testcase_48 AC 350 ms
5,644 KB
testcase_49 AC 344 ms
5,640 KB
testcase_50 AC 359 ms
5,636 KB
testcase_51 AC 354 ms
5,700 KB
testcase_52 AC 364 ms
5,656 KB
testcase_53 AC 362 ms
5,644 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)

int N, D;
pair<int, int> A[200000];
int ans[200000];

int main() {
    cin >> N >> D;
    rep(i, N) { int a; cin >> a; A[i] = { a,i }; }
    sort(A, A + N);
    rep(i, N) {
        int l = 0, r = i + 1;
        while (l + 1 < r) {
            int m = (l + r) / 2;
            if (A[i].first - A[m - 1].first >= D) l = m;
            else r = m;
        }
        ans[A[i].second] = l;
    }
    rep(i, N) cout << ans[i] << endl;
    return 0;
}
0