結果

問題 No.1265 Balloon Survival
ユーザー zuminzumin
提出日時 2021-03-28 16:32:15
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 115 ms / 2,000 ms
コード長 861 bytes
コンパイル時間 836 ms
コンパイル使用メモリ 89,616 KB
実行使用メモリ 17,180 KB
最終ジャッジ日時 2023-08-19 15:39:02
合計ジャッジ時間 3,449 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 12 ms
4,744 KB
testcase_15 AC 9 ms
4,776 KB
testcase_16 AC 4 ms
4,376 KB
testcase_17 AC 55 ms
16,256 KB
testcase_18 AC 6 ms
4,380 KB
testcase_19 AC 4 ms
4,380 KB
testcase_20 AC 11 ms
4,660 KB
testcase_21 AC 25 ms
6,520 KB
testcase_22 AC 16 ms
7,452 KB
testcase_23 AC 16 ms
7,164 KB
testcase_24 AC 107 ms
15,692 KB
testcase_25 AC 108 ms
16,968 KB
testcase_26 AC 112 ms
15,824 KB
testcase_27 AC 111 ms
15,884 KB
testcase_28 AC 111 ms
15,700 KB
testcase_29 AC 115 ms
15,888 KB
testcase_30 AC 114 ms
15,436 KB
testcase_31 AC 112 ms
15,480 KB
testcase_32 AC 108 ms
16,224 KB
testcase_33 AC 109 ms
17,180 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <queue>
#include <tuple>

using namespace std;
using ll=long long;

int main(){
    ll n,ans=0;
    cin>>n;
    vector<ll> x(n),y(n),kil(n,0);
    priority_queue<tuple<ll,ll,ll>,vector<tuple<ll,ll,ll>>,greater<tuple<ll,ll,ll>>> q;

    for(ll i=0;i<n;i++) cin>>x[i]>>y[i];
    
    for(ll i=0;i<n;i++){
        for(ll j=i+1;j<n;j++){
            ll xi,yi,xj,yj;
            xi=x[i],yi=y[i],xj=x[j],yj=y[j];
            q.push(make_tuple(powl(xi-xj,2)+powl(yi-yj,2),i,j));
        }
    }
    while(q.size()){
        ll d,i,j;
        tie(d,i,j)=q.top();q.pop();
        if(kil[i]||kil[j]) continue;
        if(i!=0&&j!=0){
            kil[i]=1;
            kil[j]=1;
        }else{
            kil[j]=1;
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}
0