結果

問題 No.202 1円玉投げ
ユーザー 158b158b
提出日時 2015-05-04 02:38:27
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,405 bytes
コンパイル時間 515 ms
コンパイル使用メモリ 58,524 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-23 22:11:42
合計ジャッジ時間 60,100 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4,084 ms
4,380 KB
testcase_01 AC 3,926 ms
4,376 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 1 ms
4,380 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 4,006 ms
4,380 KB
testcase_17 AC 4,004 ms
4,376 KB
testcase_18 AC 3,985 ms
4,376 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 3 ms
4,376 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 3 ms
4,380 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 2 ms
4,380 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 3 ms
4,380 KB
testcase_35 AC 4,003 ms
4,380 KB
testcase_36 AC 4,017 ms
4,376 KB
testcase_37 WA -
testcase_38 AC 4,023 ms
4,376 KB
testcase_39 AC 1 ms
4,376 KB
testcase_40 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

//xでソート。

#include<iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

using namespace std;

//重なったら1 そうでなければ0
int check(int loc1x, int loc1y, int loc2x, int loc2y){
	int kyori =  abs(pow(loc2x - loc1x, 2) + pow(loc2y - loc1y, 2) );
	
	//cout << "距離測定:" << loc1[0] << "," << loc1[0] << "と" << loc2[0] << "," << loc2[1] << ":" << kyori << endl;
	if(kyori < 400){
		return 1;
	}
	
	return 0;
}
	
int main(){
	int max;
	int count = 0;
	int loc[100000][2];
	int in1;
	int in2;
	int s1;
	int start;
	int end;
	int s2;
	
	cin >> max;
	for(int i=0; i<max; i++){
		//データ入力部分
		cin >> in1;
		cin >> in2;
		
		//挿入ソート(昇順)
		s1 = 0;
		while(in1 < loc[s1][0] && s1 < count){
			s1 ++;
		}
		
		//s1が挿入先
		for(s2=count; s2>=s1; s2--){
			loc[s2 + 1][0] = loc[s2][0];
			loc[s2 + 1][1] = loc[s2][1];
		}
		
		//データ挿入
		loc[s2][0] = in1;
		loc[s2][1] = in2;
		
		
		//カウント部分
		start = s2 - 100;
		if(start < 0){
			start = 0;
		}
		
		end = s2 + 100;
		if(end > count){
			end = count;
		}
		
		for(int i2=start; i2<end; i2++){
			if(check(in1, in2 ,loc[i2][0], loc[i2][1]) == 1){
				break;
			}
		}
		
		if(loc[s2][0] != -1){
			count ++;
		}
	}
	
	//中身確認
	/*
	for(int i=0; i<max; i++){
		cout << loc[i][0] << "," << loc[i][1] << endl;
	}
	*/
	cout << count << endl;
	
}

0