結果

問題 No.2923 Mayor's Job
コンテスト
ユーザー tnakao0123
提出日時 2024-10-13 17:25:34
言語 C++17
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 1,002 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 250 ms
コンパイル使用メモリ 61,024 KB
実行使用メモリ 9,228 KB
最終ジャッジ日時 2026-07-05 23:20:11
合計ジャッジ時間 1,611 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

/* -*- coding: utf-8 -*-
 *
 * 2923.cc:  No.2923 Mayor's Job - yukicoder
 */

#include<cstdio>
#include<algorithm>
#include<utility>

using namespace std;

/* constant */

const int MAX_N = 2000;

/* typedef */

using ll = long long;
using pii = pair<int,int>;

/* global variables */

int hs[MAX_N], xs[MAX_N], ys[MAX_N];
pii his[MAX_N];

/* subroutines */

ll dist2(int u, int v) {
  int dx = xs[v] - xs[u], dy = ys[v] - ys[u];
  return (ll)dx * dx + (ll)dy * dy;
}

/* main */

int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) scanf("%d", hs + i);
  for (int i = 0; i < n; i++) scanf("%d%d", xs + i, ys + i);

  for (int i = 0; i < n; i++) his[i] = {hs[i], i};
  sort(his, his + n);

  ll kk = (ll)k * k;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    auto [hu, u] = his[i];
    for (int j = i + 1; j < n; j++) {
      auto [hv, v] = his[j];
      if (hu < hv && dist2(u, v) <= kk) {
	cnt++; break;
      }
    }
  }

  printf("%d\n", n - cnt);

  return 0;
}
0