結果

問題 No.1110 好きな歌
ユーザー trineutrontrineutron
提出日時 2019-10-13 01:59:50
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 362 ms / 5,000 ms
コード長 525 bytes
コンパイル時間 2,076 ms
コンパイル使用メモリ 172,444 KB
実行使用メモリ 5,496 KB
最終ジャッジ日時 2023-10-11 11:18:01
合計ジャッジ時間 12,915 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,352 KB
testcase_01 AC 1 ms
4,352 KB
testcase_02 AC 1 ms
4,352 KB
testcase_03 AC 2 ms
4,352 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 1 ms
4,352 KB
testcase_07 AC 1 ms
4,356 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 1 ms
4,352 KB
testcase_11 AC 2 ms
4,352 KB
testcase_12 AC 1 ms
4,348 KB
testcase_13 AC 1 ms
4,352 KB
testcase_14 AC 2 ms
4,352 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 2 ms
4,352 KB
testcase_17 AC 3 ms
4,352 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 4 ms
4,352 KB
testcase_20 AC 3 ms
4,348 KB
testcase_21 AC 2 ms
4,352 KB
testcase_22 AC 3 ms
4,352 KB
testcase_23 AC 2 ms
4,352 KB
testcase_24 AC 210 ms
4,372 KB
testcase_25 AC 256 ms
5,260 KB
testcase_26 AC 134 ms
4,348 KB
testcase_27 AC 252 ms
5,112 KB
testcase_28 AC 150 ms
4,356 KB
testcase_29 AC 295 ms
5,272 KB
testcase_30 AC 149 ms
4,352 KB
testcase_31 AC 90 ms
4,352 KB
testcase_32 AC 329 ms
5,176 KB
testcase_33 AC 168 ms
4,352 KB
testcase_34 AC 228 ms
4,700 KB
testcase_35 AC 362 ms
5,496 KB
testcase_36 AC 40 ms
4,352 KB
testcase_37 AC 100 ms
4,348 KB
testcase_38 AC 293 ms
5,112 KB
testcase_39 AC 219 ms
4,912 KB
testcase_40 AC 284 ms
5,140 KB
testcase_41 AC 23 ms
4,348 KB
testcase_42 AC 317 ms
5,108 KB
testcase_43 AC 293 ms
5,112 KB
testcase_44 AC 354 ms
5,352 KB
testcase_45 AC 359 ms
5,488 KB
testcase_46 AC 354 ms
5,308 KB
testcase_47 AC 361 ms
5,384 KB
testcase_48 AC 354 ms
5,392 KB
testcase_49 AC 351 ms
5,428 KB
testcase_50 AC 357 ms
5,300 KB
testcase_51 AC 354 ms
5,348 KB
testcase_52 AC 362 ms
5,424 KB
testcase_53 AC 361 ms
5,384 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 i = 0; i < n; i++) {
        cout << ans.at(i) << endl;
    }
}
0