結果
| 問題 |
No.1110 好きな歌
|
| コンテスト | |
| ユーザー |
platinum
|
| 提出日時 | 2020-05-27 22:32:01 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 357 ms / 5,000 ms |
| コード長 | 605 bytes |
| コンパイル時間 | 1,672 ms |
| コンパイル使用メモリ | 174,412 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-13 03:53:04 |
| 合計ジャッジ時間 | 12,170 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 51 |
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)
using namespace std;
using LL = long long;
using P = pair<int,int>;
const int INF=1e9;
const int Max_N=2e5;
const int Max_A=1e9;
int main(){
int N, D;
cin >> N >> D;
assert(N>=1 && N<=Max_N);
assert(D>=1 && D<=Max_A);
vector<P> A(N);
rep(i,N){
int a;
cin >> a;
assert(a>=1 && a<=Max_A);
A[i]={a,i};
}
sort(A.begin(),A.end());
vector<int> ans(N);
rep(i,N){
int a=A[i].first;
int res=upper_bound(A.begin(),A.end(),P(a-D,INF))-A.begin();
ans[A[i].second]=res;
}
rep(i,N) cout << ans[i] << endl;
return 0;
}
platinum