結果
問題 |
No.1110 好きな歌
|
ユーザー |
![]() |
提出日時 | 2019-10-24 23:37:55 |
言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 73 ms / 5,000 ms |
コード長 | 660 bytes |
コンパイル時間 | 2,113 ms |
コンパイル使用メモリ | 164,548 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-30 15:31:00 |
合計ジャッジ時間 | 6,647 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 51 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); int n, d; cin >> n >> d; array<pair<int, int>, 200000> p; for (int i = 0; i < n; i++) { int a_i; cin >> a_i; p[i] = make_pair(a_i, i); } sort(p.begin(), p.begin() + n); array<int, 200000> a, ans; int index = 0; for (int i = 0; i < n; i++) a[i] = p[i].first; for (int i = 0; i < n; i++) { index = upper_bound(a.begin() + index, a.begin() + n, a[i] - d) - a.begin(); ans[p[i].second] = index; } for (int i = 0; i < n; i++) { cout << ans[i] << "\n"; } }