結果

問題 No.1110 好きな歌
ユーザー TeruMiyakeTeruMiyake
提出日時 2020-07-10 21:48:31
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 330 ms / 5,000 ms
コード長 3,676 bytes
コンパイル時間 2,190 ms
コンパイル使用メモリ 173,356 KB
実行使用メモリ 6,736 KB
最終ジャッジ日時 2024-04-19 16:44:07
合計ジャッジ時間 11,077 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 3 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 3 ms
5,376 KB
testcase_20 AC 3 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 3 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 176 ms
5,376 KB
testcase_25 AC 225 ms
5,708 KB
testcase_26 AC 115 ms
5,376 KB
testcase_27 AC 216 ms
5,708 KB
testcase_28 AC 131 ms
5,376 KB
testcase_29 AC 283 ms
6,220 KB
testcase_30 AC 125 ms
5,376 KB
testcase_31 AC 74 ms
5,376 KB
testcase_32 AC 289 ms
6,476 KB
testcase_33 AC 140 ms
5,376 KB
testcase_34 AC 195 ms
5,456 KB
testcase_35 AC 291 ms
6,604 KB
testcase_36 AC 34 ms
5,376 KB
testcase_37 AC 90 ms
5,376 KB
testcase_38 AC 263 ms
5,964 KB
testcase_39 AC 193 ms
5,376 KB
testcase_40 AC 227 ms
6,092 KB
testcase_41 AC 20 ms
5,376 KB
testcase_42 AC 280 ms
6,224 KB
testcase_43 AC 260 ms
6,192 KB
testcase_44 AC 297 ms
6,608 KB
testcase_45 AC 313 ms
6,728 KB
testcase_46 AC 311 ms
6,604 KB
testcase_47 AC 316 ms
6,476 KB
testcase_48 AC 316 ms
6,604 KB
testcase_49 AC 289 ms
6,600 KB
testcase_50 AC 313 ms
6,604 KB
testcase_51 AC 303 ms
6,736 KB
testcase_52 AC 311 ms
6,476 KB
testcase_53 AC 330 ms
6,608 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ld  = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
const int INF=1e9+7;
const ll LINF=9223372036854775807;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld EPS = 1e-10; //微調整用(EPSより小さいと0と判定など)

int ii() { int x; if (scanf("%d", &x)==1) return x; else return 0; }
long long il() { long long x; if (scanf("%lld", &x)==1) return x; else return 0; }
string is() { string x; cin >> x; return x; }
char ic() { char x; cin >> x; return x; }
void oi(int x) { printf("%d ", x); }
void ol(long long x) { printf("%lld ", x); }
void od_nosp(double x) { printf("%.15f", x); } // 古い問題用
void od(double x) { printf("%.15f ", x); }
// long doubleで受け取り、fをLfなどに変えて出力すると、変な数値が出る
// それをなんとかするには独自の出力を作らなければならなそう
void os(const string &s) { printf("%s ", s.c_str()); }
void oc(const char &c) { printf("%c ", c); }
#define o_map(v){cerr << #v << endl; for(const auto& xxx: v){cout << xxx.first << " " << xxx.second << "\n";}} //動作未確認
void br() { putchar('\n'); }

// #define gcd __gcd //llは受け取らない C++17~のgcdと違うので注意
// int lcm(int a, int b){return a / gcd(a, b) * b;}
#define begin_end(a) a.begin(),a.end() //sort(begin_end(vec));
#define REP(i,m,n) for(ll i=(ll)(m) ; i < (ll) (n) ; i++ )
#define rep(i,n) REP(i,0,n)
#define m_p(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define p_b push_back
#define SZ(x) ((int)(x).size) //size()がunsignedなのでエラー避けに


// coutによるpairの出力(空白区切り)
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << " " << p.second << ")";}
// coutによるvectorの出力(空白区切り)
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << " "; //"\t"に変えるとTabで見やすく区切る
  }
  return s;
}
// coutによる多次元vectorの出力(空白区切り)
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i] << endl;
  }
  return s;
}

//最大値、最小値の更新。更新したor等しければtrueを返す
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}

//4近傍(上下左右) rep(i, 2) にすると右・下だけに進む
vector<int> dx_4 = {1, 0, -1, 0};
vector<int> dy_4 = {0, 1, 0, -1};

// -------- template end - //


// - library ------------- //


//与えられたstringが回文かどうかを返す関数
bool isPal(string s){
  string revS = s;
  reverse(revS.begin(), revS.end());
  return s==revS;
}

// --------- library end - //


int main(){

  ll N, D;
  cin >> N >> D;
  vector<ll> as;
  rep(i, N){
    as.push_back(il());
  }

  vector<ll> as_sorted = as;
  sort(begin_end(as_sorted)); // 昇順

  rep(i, N){
    ll tg = as[i] - D;
    // 昇順に並んでいるasにおいて、as[i]-D 以下であるようなas[j]がいくつあるか
    // as[i]-D より大きいものを数え、それを引けばいい

    ll lowers = as_sorted.end() - upper_bound(begin_end(as_sorted), tg);
    cout << N - lowers << endl;
  }

}
0