結果
問題 |
No.1110 好きな歌
|
ユーザー |
![]() |
提出日時 | 2019-10-24 23:32:24 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 126 ms / 5,000 ms |
コード長 | 508 bytes |
コンパイル時間 | 1,734 ms |
コンパイル使用メモリ | 176,128 KB |
実行使用メモリ | 5,708 KB |
最終ジャッジ日時 | 2024-09-13 10:23:23 |
合計ジャッジ時間 | 7,353 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 51 |
ソースコード
#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"; } }