結果

問題 No.1110 好きな歌
コンテスト
ユーザー trineutron
提出日時 2019-10-12 18:39:16
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
RE  
実行時間 -
コード長 677 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,324 ms
コンパイル使用メモリ 190,288 KB
実行使用メモリ 7,972 KB
最終ジャッジ日時 2026-04-04 04:36:09
合計ジャッジ時間 6,538 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29 RE * 22
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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

int main() {
    int n, d;
    cin >> n >> d;
    assert(1 <= n && n <= 100000);
    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.at(i) = p.at(i).first;
    for (int i = 0; i < n; i++) {
        ans.at(p.at(i).second) = upper_bound(a.begin(), a.end(), a.at(i) - d) - a.begin();
    }
    for (int i = 0; i < n; i++) {
        cout << ans.at(i) << endl;
    }
}
0