結果

問題 No.2923 Mayor's Job
ユーザー MM
提出日時 2024-10-12 15:10:51
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 154 ms / 2,000 ms
コード長 1,413 bytes
コンパイル時間 6,054 ms
コンパイル使用メモリ 337,744 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-12 15:11:04
合計ジャッジ時間 7,067 ms
ジャッジサーバーID
(参考情報)
judge / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/all>
#define chmin(x,y) (x) = min((x),(y))
#define chmax(x,y) (x) = max((x),(y))z
using namespace std;
using namespace atcoder;
using ll = long long;
const ll mod = 998244353;
using mint = modint998244353;
using Graph = vector<vector<pair<int,ll>>>;
const vector<int> dx = {1,0,-1,0}, dy = {0,1,0,-1};

double dist(int x1, int y1, int x2, int y2){
  double res = (x1-x2) * (x1-x2) + (y1-y2) * (y1-y2);
  return sqrt(res);
}

ll need(ll n, ll m){
  ll res = 0;
  if(n < 0) return res;
  res = n / m;
  if(n % m > 0) res++;
  return res;
}

ll d2(ll x1, ll y1, ll x2, ll y2){
  // auto [x1,y1] = p;
  // auto [x2,y2] = q;
  ll res = (x1-x2) * (x1-x2) + (y1-y2) * (y1-y2);
  return res;
}

int main(){
  // input
  int N; ll K;
  cin >> N >> K;
  vector<int> H(N), X(N), Y(N);
  for(int i = 0; i < N; i++) cin >> H[i];
  for(int i = 0; i < N; i++) cin >> X[i] >> Y[i];
  
  // prep
  priority_queue<vector<int>> pq;
  for(int i = 0; i < N; i++)
    pq.push({-H[i],X[i],Y[i]});
  
  
  // solve
  vector<vector<ll>> rem;
  for(int i = 0; i < N; i++){
    int h1 = -pq.top()[0];
    ll x1 = pq.top()[1], y1 = pq.top()[2];
    pq.pop();
    
    vector<vector<ll>> nxt;
    for(auto v : rem){
      if(v[0] >= h1 || d2(v[1],v[2],x1,y1) > K*K)
        nxt.push_back(v);
    }
    swap(rem,nxt);
    rem.push_back({h1,x1,y1});
  }
  
  
  // output
  cout << rem.size() << endl;
}
0