結果
問題 |
No.2923 Mayor's Job
|
ユーザー |
![]() |
提出日時 | 2024-10-19 15:27:09 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 32 ms / 2,000 ms |
コード長 | 843 bytes |
コンパイル時間 | 971 ms |
コンパイル使用メモリ | 81,040 KB |
最終ジャッジ日時 | 2025-02-24 21:34:21 |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> using namespace std; using ll = long long; ll d2(ll x1, ll y1, ll x2, ll y2){ return (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1); } int main(){ int n; ll k; cin >> n >> k; vector<ll> h(n); for (ll &i: h) cin >> i; vector<ll> x(n), y(n); for (int i = 0; i < n; i++){ cin >> x[i] >> y[i]; } vector<int> ind(n); for (int i = 0; i < n; i++) ind[i] = i; sort(ind.begin(), ind.end(), [&](int a, int b) { return h[a] < h[b]; }); int ans = 0; for (int i = 0; i < n; i++){ int a = ind[i]; bool ok = true; for (int j = i + 1; j < n; j++){ int b = ind[j]; if (h[a] == h[b]) continue; if (d2(x[a], y[a], x[b], y[b]) <= k * k){ ok = false; break; } } if (ok) ans++; } cout << ans << endl; }