結果

問題 No.1110 好きな歌
ユーザー rgkb0303rgkb0303
提出日時 2020-07-20 09:22:54
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 366 ms / 5,000 ms
コード長 586 bytes
コンパイル時間 1,575 ms
コンパイル使用メモリ 172,696 KB
実行使用メモリ 5,668 KB
最終ジャッジ日時 2023-08-24 18:44:03
合計ジャッジ時間 16,752 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 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 2 ms
4,380 KB
testcase_06 AC 1 ms
4,384 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 3 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 4 ms
4,376 KB
testcase_20 AC 3 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 3 ms
4,376 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 216 ms
4,592 KB
testcase_25 AC 260 ms
5,236 KB
testcase_26 AC 134 ms
4,380 KB
testcase_27 AC 256 ms
5,224 KB
testcase_28 AC 146 ms
4,376 KB
testcase_29 AC 292 ms
5,216 KB
testcase_30 AC 149 ms
4,380 KB
testcase_31 AC 89 ms
4,380 KB
testcase_32 AC 331 ms
5,132 KB
testcase_33 AC 168 ms
4,380 KB
testcase_34 AC 230 ms
4,656 KB
testcase_35 AC 352 ms
5,392 KB
testcase_36 AC 40 ms
4,376 KB
testcase_37 AC 98 ms
4,380 KB
testcase_38 AC 287 ms
5,060 KB
testcase_39 AC 219 ms
4,696 KB
testcase_40 AC 283 ms
5,116 KB
testcase_41 AC 23 ms
4,376 KB
testcase_42 AC 322 ms
5,096 KB
testcase_43 AC 295 ms
5,104 KB
testcase_44 AC 357 ms
5,476 KB
testcase_45 AC 364 ms
5,484 KB
testcase_46 AC 362 ms
5,668 KB
testcase_47 AC 360 ms
5,296 KB
testcase_48 AC 364 ms
5,296 KB
testcase_49 AC 350 ms
5,416 KB
testcase_50 AC 362 ms
5,656 KB
testcase_51 AC 360 ms
5,372 KB
testcase_52 AC 366 ms
5,644 KB
testcase_53 AC 357 ms
5,296 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
  int n, d;
  cin >> n >> d;
  
  vector<pair<int, int>> v;
  
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    v.push_back(make_pair(a, i));
  }
  sort(v.begin(), v.end());
  
  vector<int> answer(n, 0);
  
  int count = 0;
  int num = 0;
  
  for (int i = 0; i < n; i++) {
    while (v.at(i).first - d >= v.at(num).first) {
      count++;
      num++;
    }
    if (v.at(i).first - d < v.at(num).first) {
      answer.at(v.at(i).second) = count;
    }
  }
  
  for (int x : answer) {
    cout << x << endl;
  }
}
0