結果
| 問題 |
No.2923 Mayor's Job
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-01-19 11:45:42 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 30 ms / 2,000 ms |
| コード長 | 1,244 bytes |
| コンパイル時間 | 967 ms |
| コンパイル使用メモリ | 81,752 KB |
| 実行使用メモリ | 19,456 KB |
| 最終ジャッジ日時 | 2025-01-19 11:46:24 |
| 合計ジャッジ時間 | 1,833 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:17:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
17 | scanf("%d%d",&n,&k);
| ~~~~~^~~~~~~~~~~~~~
main.cpp:22:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
22 | scanf("%d",&h[i]);
| ~~~~~^~~~~~~~~~~~
main.cpp:27:18: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
27 | rep(i,n)scanf("%d%d",&xy[i].first,&xy[i].second);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<cassert>
#define rep(i,n) for(i=0;i<(int)(n);i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
int n,k;
int main(){
int i,j,ii;
scanf("%d%d",&n,&k);
vector<int> h(n);
vector<P> hs;//(id,h)
vector<bool> exist(n,true);
rep(i,n){
scanf("%d",&h[i]);
hs.push_back(P(h[i],i));
}
sort(hs.begin(),hs.end());
vector<P> xy(n);
rep(i,n)scanf("%d%d",&xy[i].first,&xy[i].second);
vector<vector<int> > adj(n);
auto judge=[&](int a,int b)->bool{
return ((ll)xy[a].first-xy[b].first)*((ll)xy[a].first-xy[b].first)+((ll)xy[a].second-xy[b].second)*((ll)xy[a].second-xy[b].second)<=(ll)k*k;
};
rep(i,n)rep(j,i){
if(judge(i,j)){
adj[i].push_back(j);
adj[j].push_back(i);
}
}
ii=n;
rep(i,n)if(exist[hs[i].second]){
rep(j,adj[hs[i].second].size()){
if(exist[adj[hs[i].second][j]]&&hs[i].first<h[adj[hs[i].second][j]]){
exist[hs[i].second]=false;
ii--;
break;
}
}
}
printf("%d\n",ii);
return 0;
}