結果

問題 No.1110 好きな歌
ユーザー trineutron
提出日時 2019-10-22 11:58:29
言語 C++17(clang)
(17.0.6 + boost 1.87.0)
結果
AC  
実行時間 132 ms / 5,000 ms
コード長 659 bytes
コンパイル時間 2,298 ms
コンパイル使用メモリ 164,756 KB
実行使用メモリ 6,476 KB
最終ジャッジ日時 2024-11-30 15:29:13
合計ジャッジ時間 8,530 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 51
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    int n, d;
    cin >> n >> d;
    assert(1 <= n && n <= 200000);
    assert(1 <= d && d <= 1000000000);
    vector<pair<int, int>> p;
    for (int i = 0; i < n; i++) {
        int a_i;
        cin >> a_i;
        assert(1 <= a_i && a_i <= 1000000000);
        p.emplace_back(a_i, i);
    }
    sort(p.begin(), p.end());
    vector<int> a(n), ans(n);
    for (int i = 0; i < n; i++) a[i] = p[i].first;
    for (int i = 0; i < n; i++) {
        ans[p[i].second] = upper_bound(a.begin(), a.end(), a[i] - d) - a.begin();
    }
    for (int i = 0; i < n; i++) {
        cout << ans[i] << "\n";
    }
}
0