結果
| 問題 |
No.1265 Balloon Survival
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-10-23 22:26:05 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 68 ms / 2,000 ms |
| コード長 | 767 bytes |
| コンパイル時間 | 2,189 ms |
| コンパイル使用メモリ | 178,180 KB |
| 実行使用メモリ | 11,744 KB |
| 最終ジャッジ日時 | 2024-07-21 11:08:53 |
| 合計ジャッジ時間 | 4,063 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 32 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
int main(){
vector<pair<long long,pair<int,int>>> vc;
int n;
cin >> n;
vector<long long> a(n),b(n);
for(int i=0;i<n;i++){
cin >> a[i] >> b[i];
}
for(int i=0;i<n;i++){
for(int j=i+1;j<n;j++){
long long cost=0;
cost+=(a[i]-a[j])*(a[i]-a[j]);
cost+=(b[i]-b[j])*(b[i]-b[j]);
vc.push_back(make_pair(cost,make_pair(i,j)));
}
}
sort(vc.begin(),vc.end());
int cnt=vc.size(),res=0;
vector<int> fl(n,0);
for(int i=0;i<cnt;i++){
pair<int,int> conf=vc[i].second;
int p=conf.first,q=conf.second;
if(fl[p]==1 || fl[q]==1){continue;}
//cout << p << q << '\n';
if(p==0){res++;fl[q]=1;continue;}
fl[p]=1;fl[q]=1;
}
cout << res << '\n';
return 0;
}