結果
| 問題 | No.2923 Mayor's Job | 
| コンテスト | |
| ユーザー |  tnakao0123 | 
| 提出日時 | 2024-10-13 17:25:34 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 15 ms / 2,000 ms | 
| コード長 | 1,002 bytes | 
| コンパイル時間 | 716 ms | 
| コンパイル使用メモリ | 45,692 KB | 
| 最終ジャッジ日時 | 2025-02-24 19:18:53 | 
| ジャッジサーバーID (参考情報) | judge2 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 17 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:37:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   37 |   scanf("%d%d", &n, &k);
      |   ~~~~~^~~~~~~~~~~~~~~~
main.cpp:38:36: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   38 |   for (int i = 0; i < n; i++) scanf("%d", hs + i);
      |                               ~~~~~^~~~~~~~~~~~~~
main.cpp:39:36: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   39 |   for (int i = 0; i < n; i++) scanf("%d%d", xs + i, ys + i);
      |                               ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
            
            ソースコード
/* -*- 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;
}
            
            
            
        