結果

問題 No.1110 好きな歌
ユーザー tsushimatsushima
提出日時 2020-07-10 22:12:19
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 479 ms / 5,000 ms
コード長 749 bytes
コンパイル時間 2,156 ms
コンパイル使用メモリ 209,396 KB
実行使用メモリ 14,344 KB
最終ジャッジ日時 2023-08-01 18:14:02
合計ジャッジ時間 15,172 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 3 ms
4,376 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 1 ms
4,380 KB
testcase_19 AC 3 ms
4,376 KB
testcase_20 AC 3 ms
4,380 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 3 ms
4,376 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 255 ms
9,788 KB
testcase_25 AC 330 ms
10,948 KB
testcase_26 AC 159 ms
6,936 KB
testcase_27 AC 324 ms
10,628 KB
testcase_28 AC 173 ms
7,552 KB
testcase_29 AC 385 ms
12,004 KB
testcase_30 AC 174 ms
7,520 KB
testcase_31 AC 102 ms
5,732 KB
testcase_32 AC 433 ms
13,136 KB
testcase_33 AC 200 ms
8,380 KB
testcase_34 AC 282 ms
10,176 KB
testcase_35 AC 460 ms
13,928 KB
testcase_36 AC 43 ms
4,816 KB
testcase_37 AC 114 ms
6,084 KB
testcase_38 AC 374 ms
12,032 KB
testcase_39 AC 277 ms
9,568 KB
testcase_40 AC 357 ms
11,796 KB
testcase_41 AC 23 ms
4,380 KB
testcase_42 AC 409 ms
12,744 KB
testcase_43 AC 372 ms
11,944 KB
testcase_44 AC 461 ms
13,800 KB
testcase_45 AC 470 ms
13,808 KB
testcase_46 AC 465 ms
14,192 KB
testcase_47 AC 464 ms
14,344 KB
testcase_48 AC 468 ms
13,908 KB
testcase_49 AC 461 ms
14,312 KB
testcase_50 AC 465 ms
13,796 KB
testcase_51 AC 474 ms
13,800 KB
testcase_52 AC 469 ms
13,808 KB
testcase_53 AC 479 ms
13,860 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n, d;
  cin >> n >> d;
  vector<int> org(n), a(n);
  rep(i, 0, n) {
    cin >> a[i];
    org[i] = a[i];
  }
  sort(a.begin(), a.end());

  map<int, int> mp;
  rep(i, 0, n) {
    int key = a[i] - d;
    int x = 0;
    if (key > 0)
      x = upper_bound(a.begin(), a.end(), key) - a.begin();

    mp[a[i]] = x;
  }

  rep(i, 0, n) cout << mp[org[i]] << endl;
}
0