結果
問題 |
No.2923 Mayor's Job
|
ユーザー |
|
提出日時 | 2024-10-12 14:42:30 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 12 ms / 2,000 ms |
コード長 | 889 bytes |
コンパイル時間 | 2,186 ms |
コンパイル使用メモリ | 199,148 KB |
最終ジャッジ日時 | 2025-02-24 17:39:25 |
ジャッジサーバーID (参考情報) |
judge3 / judge |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; template<class T> istream& operator >> (istream& is, vector<T>& vec) { for(T& x : vec) is >> x; return is; } int main(){ ios::sync_with_stdio(false); cin.tie(0); ll n, k; cin >> n >> k; vector<ll> h(n); vector<pair<ll,ll>> a(n); cin >> h; for(auto &&[x, y] : a){ cin >> x >> y; } auto f = [&](int i, int j){ auto [x1, y1] = a[i]; auto [x2, y2] = a[j]; ll dx = x1 - x2, dy = y1 - y2; return dx * dx + dy * dy <= k * k; }; vector<bool> used(n); for(int i = 0; i < n; i++){ for(int j = i + 1; j < n; j++){ if(!f(i, j)) continue; if(h[i] > h[j]) used[j] = true; else if(h[i] < h[j]) used[i] = true; } } cout << n - count(used.begin(), used.end(), true) << '\n'; }