結果

問題 No.1265 Balloon Survival
ユーザー kyoprounokyoprouno
提出日時 2020-10-23 22:31:55
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 166 ms / 2,000 ms
コード長 1,297 bytes
コンパイル時間 2,124 ms
コンパイル使用メモリ 182,836 KB
実行使用メモリ 17,176 KB
最終ジャッジ日時 2023-09-28 16:38:41
合計ジャッジ時間 5,356 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,384 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,384 KB
testcase_14 AC 15 ms
4,744 KB
testcase_15 AC 13 ms
4,888 KB
testcase_16 AC 5 ms
4,380 KB
testcase_17 AC 79 ms
15,880 KB
testcase_18 AC 7 ms
4,376 KB
testcase_19 AC 6 ms
4,380 KB
testcase_20 AC 15 ms
4,696 KB
testcase_21 AC 35 ms
6,324 KB
testcase_22 AC 22 ms
6,304 KB
testcase_23 AC 24 ms
6,192 KB
testcase_24 AC 164 ms
15,612 KB
testcase_25 AC 164 ms
16,260 KB
testcase_26 AC 161 ms
15,760 KB
testcase_27 AC 161 ms
17,176 KB
testcase_28 AC 160 ms
15,740 KB
testcase_29 AC 163 ms
15,620 KB
testcase_30 AC 162 ms
15,616 KB
testcase_31 AC 164 ms
16,044 KB
testcase_32 AC 163 ms
15,932 KB
testcase_33 AC 166 ms
16,592 KB
testcase_34 AC 2 ms
4,380 KB
testcase_35 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

const ll INF=1e9+10;

int main(){
    ll n;
    cin >> n;
    vector<ll> x(n),y(n);
    rep(i,n){
        cin >> x[i] >> y[i];
    }
    priority_queue<pair<ll,pll>> PQ;
    vector<ll> used(n);
    ll ans=0;
    rep(i,n){
        for(ll j=i+1;j<n;j++){
            ll dx=abs(x[i]-x[j]),dy=abs(y[i]-y[j]);
            ll d=dx*dx+dy*dy;
            pair<ll,pll> x;
            x.fi=-d;
            x.se.fi=i,x.se.se=j;
            PQ.push(x);
        }
    }
    while(!PQ.empty()){
        pair<ll,pll> x;
        x=PQ.top();
        PQ.pop();
        if(used[x.se.fi] || used[x.se.se]) continue;
        if(x.se.fi==0){
            ans++;
            used[x.se.se]=1;
        }
        else{
            used[x.se.fi]=1,used[x.se.se]=1;
            
        }
    }
    cout << ans << endl;
    return 0;
}
0