結果
問題 | No.1110 好きな歌 |
ユーザー |
![]() |
提出日時 | 2020-07-10 22:40:55 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 83 ms / 5,000 ms |
コード長 | 1,406 bytes |
コンパイル時間 | 1,727 ms |
コンパイル使用メモリ | 173,200 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-11 10:02:08 |
合計ジャッジ時間 | 6,317 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 51 |
ソースコード
#include <bits/stdc++.h> #define rep(X,N) for(ll X = 0LL; X < (N); X++) #define ALL(V) (V).begin(),(V).end() #define endl "\n" using namespace std; typedef long long ll; const double PI = 3.1415926535897932384626; const ll MODN = 1000000007; const ll MODN2 = 998244353; const double EPS = 1e-10; //ソート済み配列に対して、指定した数以下の個数を返す関数 template<typename T> inline int less_or_eq_count(std::vector<T> v, T x, int size){ int ok = -1; int ng = size; while(ng - ok > 1){ int tmp = (ok + ng) / 2; if(v[tmp] <= x){ ok = tmp; }else ng = tmp; } return ok + 1; } //最大値 ULONG_MAX inline uint32_t xor128(void) { static uint32_t x = 123456789; static uint32_t y = 362436069; static uint32_t z = 521288629; static uint32_t w = 88675123; uint32_t t; t = x ^ (x << 11); x = y; y = z; z = w; return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); } int main(){ std::ios::sync_with_stdio(false); std::cin.tie(0); int n, d; cin >> n >> d; assert(n <= 200000); vector<int> a(n); vector<int> v(n); int tmp; rep(i, n){ cin >> tmp; a[i] = tmp; v[i] = a[i]; } sort(ALL(v)); rep(i, n){ int tmp = a[i] - d; auto it = upper_bound(ALL(v), tmp); cout << it - v.begin() << endl; } return 0; }