結果
| 問題 |
No.1110 好きな歌
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-07-10 21:33:43 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 75 ms / 5,000 ms |
| コード長 | 718 bytes |
| コンパイル時間 | 1,799 ms |
| コンパイル使用メモリ | 176,076 KB |
| 実行使用メモリ | 8,608 KB |
| 最終ジャッジ日時 | 2024-10-11 08:03:17 |
| 合計ジャッジ時間 | 6,186 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 51 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr char newl = '\n';
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
int n;
ll d;
cin >> n >> d;
vector<ll> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
vector<int> ids(n);
iota(ids.begin(), ids.end(), 0);
sort(ids.begin(), ids.end(), [&](int i1, int i2){
return a[i1] < a[i2];
});
vector<int> ans(n, 0);
vector<ll> v;
for (int i : ids) {
ans[i] = upper_bound(v.begin(), v.end(), a[i] - d) - v.begin();
v.push_back(a[i]);
}
for (int i = 0; i < n; i++) {
cout << ans[i] << newl;
}
return 0;
}