結果

問題 No.202 1円玉投げ
ユーザー fiord
提出日時 2016-02-04 17:44:18
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 1,463 ms / 5,000 ms
コード長 686 bytes
コンパイル時間 1,654 ms
コンパイル使用メモリ 166,232 KB
実行使用メモリ 8,704 KB
最終ジャッジ日時 2024-12-22 10:06:18
合計ジャッジ時間 11,793 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 38
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int dist(int x1,int y1,int x2,int y2){
	return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
}
int main(){
	int n;	cin>>n;
	vector<int> x(n),y(n);
	for(int i=0;i<n;i++)	cin>>x[i]>>y[i];
	set<pair<int,int>> grd;
	int cnt=0;
	for(int i=0;i<n;i++){
		auto it=grd.lower_bound(make_pair(x[i]-20,y[i]-20));
		bool canput=true;
		while(it!=grd.end()&&it->first<=x[i]+20){
			if(dist(x[i],y[i],it->first,it->second)<400){
				canput=false;
				break;
			}
			if(y[i]+20<it->second){
				it=grd.lower_bound(make_pair(it->first+1,y[i]-20));
			}
			else it++;
		}
		if(canput){
			grd.insert(make_pair(x[i],y[i]));
			cnt++;
		}
	}
	cout<<cnt<<endl;
	return 0;
}
0