結果
| 問題 |
No.1110 好きな歌
|
| コンテスト | |
| ユーザー |
Sooh31
|
| 提出日時 | 2020-08-19 17:22:52 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 751 ms / 5,000 ms |
| コード長 | 917 bytes |
| コンパイル時間 | 3,386 ms |
| コンパイル使用メモリ | 204,952 KB |
| 最終ジャッジ日時 | 2025-01-13 03:52:40 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 51 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
using ll = long long;
using graph = vector<vector<int>>;
const ll mod = 1000000007;
const int INF = 1001001001;
int main(){
int n, d; cin >> n >> d;
vector<pair<int, int>> ID(n);
vector<int> a(n), sorted(n);
vector<int> ans(n);
for(int i = 0; i < n; i++){
cin >> a[i];
ID[i] = make_pair(a[i], i);
}
sorted = a;
sort(sorted.begin(), sorted.end());
sort(ID.begin(), ID.end());
for(int i = 0; i < n; i++){
if(i >= 1 && ID[i].first == ID[i-1].first){
ans[ID[i].second] = ans[ID[i-1].second];
continue;
}
//cout << sorted[i] - d << endl;
int cnt = upper_bound(sorted.begin(), sorted.end(), sorted[i] - d) - sorted.begin();
ans[ID[i].second] = cnt;
}
for(int i = 0; i < n; i++) cout << ans[i] << endl;
}
Sooh31