結果
問題 |
No.1110 好きな歌
|
ユーザー |
![]() |
提出日時 | 2020-07-10 21:41:58 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 176 ms / 5,000 ms |
コード長 | 844 bytes |
コンパイル時間 | 1,808 ms |
コンパイル使用メモリ | 172,304 KB |
実行使用メモリ | 8,064 KB |
最終ジャッジ日時 | 2024-10-11 08:32:31 |
合計ジャッジ時間 | 8,003 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 51 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> P; #define DUMP(x) cout << #x << " = " << (x) << endl; #define FOR(i, m, n) for (ll i = m; i < n; i++) #define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--) #define REP(i, n) FOR(i, 0, n) #define IREP(i, n) IFOR(i, 0, n) #define FOREACH(x, a) for (auto&(x) : (a)) #define ALL(v) (v).begin(), (v).end() #define SZ(x) ll(x.size()) int main() { ll n, d; cin >> n >> d; vector<ll> a(n); REP(i, n) { cin >> a[i]; } vector<ll> ord(n); iota(ALL(ord), 0); sort(ALL(ord), [&](ll i, ll j) { return a[i] < a[j]; }); vector<ll> ans(n, 0); REP(i, n) { ll ok = -1, ng = n; while (ok + 1 < ng) { ll m = (ok + ng) / 2; (a[i] - a[ord[m]] >= d ? ok : ng) = m; } ans[i] = ok + 1; } REP(i, n) { cout << ans[i] << "\n"; } }