結果

問題 No.1265 Balloon Survival
ユーザー mamimume____momamimume____mo
提出日時 2020-11-29 18:44:07
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 111 ms / 2,000 ms
コード長 754 bytes
コンパイル時間 1,735 ms
コンパイル使用メモリ 177,376 KB
実行使用メモリ 12,996 KB
最終ジャッジ日時 2023-10-11 02:31:14
合計ジャッジ時間 5,803 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,352 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 1 ms
4,352 KB
testcase_05 AC 2 ms
4,352 KB
testcase_06 AC 2 ms
4,352 KB
testcase_07 AC 1 ms
4,352 KB
testcase_08 AC 2 ms
4,352 KB
testcase_09 AC 2 ms
4,356 KB
testcase_10 AC 1 ms
4,352 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 1 ms
4,352 KB
testcase_13 AC 2 ms
4,372 KB
testcase_14 AC 12 ms
4,352 KB
testcase_15 AC 9 ms
4,376 KB
testcase_16 AC 5 ms
4,352 KB
testcase_17 AC 54 ms
11,716 KB
testcase_18 AC 6 ms
4,500 KB
testcase_19 AC 5 ms
4,356 KB
testcase_20 AC 12 ms
4,376 KB
testcase_21 AC 25 ms
5,144 KB
testcase_22 AC 16 ms
5,248 KB
testcase_23 AC 18 ms
5,064 KB
testcase_24 AC 103 ms
11,424 KB
testcase_25 AC 104 ms
11,628 KB
testcase_26 AC 111 ms
12,996 KB
testcase_27 AC 109 ms
12,264 KB
testcase_28 AC 107 ms
11,576 KB
testcase_29 AC 108 ms
12,100 KB
testcase_30 AC 105 ms
12,004 KB
testcase_31 AC 104 ms
11,820 KB
testcase_32 AC 104 ms
12,056 KB
testcase_33 AC 105 ms
11,708 KB
testcase_34 AC 1 ms
4,356 KB
testcase_35 AC 2 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	priority_queue<tuple<ll,int,int>,vector<tuple<ll,int,int>>,greater<tuple<ll,int,int>>> que;

	int N;
	cin >> N;
	vector<ll> x(N);
	vector<ll> y(N);
	for(int i = 0;i < N;i++){
		cin >> x[i] >> y[i];
	}

	for(int i = 0;i < N-1;i++){
		for(int j = i+1;j < N;j++){
			ll x1 = x[i];
			ll x2 = x[j];
			ll y1 = y[i];
			ll y2 = y[j];
			que.push(make_tuple((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2),i,j));
		}
	}

	vector<bool> used(N,false);
	int cnt = 0;
	while(que.size()){
		ll d,i,j;
		tie(d,i,j) = que.top();
		que.pop();
		if(used[i] || used[j])continue;
		if(i == 0 || j == 0){
			cnt++;
			used[max(i,j)] = true;
		}
		else used[i] = used[j] = true;
	}

	cout << cnt << endl;
}
0