結果

問題 No.1110 好きな歌
ユーザー batsumarubatsumaru
提出日時 2020-07-10 21:41:58
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 181 ms / 5,000 ms
コード長 844 bytes
コンパイル時間 1,964 ms
コンパイル使用メモリ 168,952 KB
実行使用メモリ 8,192 KB
最終ジャッジ日時 2024-04-19 16:27:24
合計ジャッジ時間 7,969 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 94 ms
6,272 KB
testcase_25 AC 117 ms
6,528 KB
testcase_26 AC 63 ms
5,376 KB
testcase_27 AC 116 ms
6,656 KB
testcase_28 AC 63 ms
5,376 KB
testcase_29 AC 146 ms
7,040 KB
testcase_30 AC 57 ms
5,376 KB
testcase_31 AC 37 ms
5,376 KB
testcase_32 AC 157 ms
7,552 KB
testcase_33 AC 62 ms
5,504 KB
testcase_34 AC 94 ms
6,400 KB
testcase_35 AC 134 ms
7,936 KB
testcase_36 AC 15 ms
5,376 KB
testcase_37 AC 44 ms
5,376 KB
testcase_38 AC 141 ms
7,040 KB
testcase_39 AC 103 ms
6,016 KB
testcase_40 AC 107 ms
6,944 KB
testcase_41 AC 11 ms
5,376 KB
testcase_42 AC 129 ms
7,424 KB
testcase_43 AC 137 ms
7,168 KB
testcase_44 AC 146 ms
8,192 KB
testcase_45 AC 162 ms
8,064 KB
testcase_46 AC 161 ms
7,936 KB
testcase_47 AC 181 ms
8,064 KB
testcase_48 AC 159 ms
8,192 KB
testcase_49 AC 128 ms
7,936 KB
testcase_50 AC 159 ms
8,064 KB
testcase_51 AC 149 ms
7,936 KB
testcase_52 AC 161 ms
7,936 KB
testcase_53 AC 178 ms
7,936 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n, d;
  cin >> n >> d;
  vector<ll> a(n);
  REP(i, n) { cin >> a[i]; }
  vector<ll> ord(n);
  iota(ALL(ord), 0);
  sort(ALL(ord), [&](ll i, ll j) { return a[i] < a[j]; });
  vector<ll> ans(n, 0);

  REP(i, n) {
    ll ok = -1, ng = n;
    while (ok + 1 < ng) {
      ll m = (ok + ng) / 2;
      (a[i] - a[ord[m]] >= d ? ok : ng) = m;
    }
    ans[i] = ok + 1;
  }

  REP(i, n) { cout << ans[i] << "\n"; }
}
0