結果

問題 No.1110 好きな歌
ユーザー trineutrontrineutron
提出日時 2019-10-24 23:33:00
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 113 ms / 5,000 ms
コード長 508 bytes
コンパイル時間 2,109 ms
コンパイル使用メモリ 163,920 KB
実行使用メモリ 5,712 KB
最終ジャッジ日時 2024-05-07 19:50:04
合計ジャッジ時間 7,142 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 1 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 1 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 63 ms
5,376 KB
testcase_25 AC 78 ms
5,452 KB
testcase_26 AC 41 ms
5,376 KB
testcase_27 AC 78 ms
5,580 KB
testcase_28 AC 44 ms
5,376 KB
testcase_29 AC 89 ms
5,456 KB
testcase_30 AC 44 ms
5,376 KB
testcase_31 AC 28 ms
5,376 KB
testcase_32 AC 104 ms
5,584 KB
testcase_33 AC 51 ms
5,376 KB
testcase_34 AC 69 ms
5,376 KB
testcase_35 AC 107 ms
5,584 KB
testcase_36 AC 13 ms
5,376 KB
testcase_37 AC 31 ms
5,376 KB
testcase_38 AC 95 ms
5,452 KB
testcase_39 AC 66 ms
5,376 KB
testcase_40 AC 89 ms
5,452 KB
testcase_41 AC 8 ms
5,376 KB
testcase_42 AC 101 ms
5,376 KB
testcase_43 AC 94 ms
5,452 KB
testcase_44 AC 107 ms
5,576 KB
testcase_45 AC 110 ms
5,580 KB
testcase_46 AC 113 ms
5,708 KB
testcase_47 AC 111 ms
5,524 KB
testcase_48 AC 107 ms
5,580 KB
testcase_49 AC 104 ms
5,708 KB
testcase_50 AC 106 ms
5,708 KB
testcase_51 AC 106 ms
5,712 KB
testcase_52 AC 112 ms
5,580 KB
testcase_53 AC 109 ms
5,632 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
    int n, d;
    cin >> n >> d;
    vector<pair<int, int>> p;
    for (int i = 0; i < n; i++) {
        int a_i;
        cin >> a_i;
        p.emplace_back(a_i, i);
    }
    sort(p.begin(), p.end());
    int index = 0;
    vector<int> ans(n);
    for (int i = 0; i < n; i++) {
        while (p.at(i).first - p.at(index).first >= d) index++;
        ans.at(p.at(i).second) = index;
    }
    for (int x : ans) {
        cout << x << "\n";
    }
}
0