답안 #3935

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
3935 2013-08-31T09:29:37 Z zzapcoder Jogging (kriii1_J) C++
0 / 1
1000 ms 4980 KB
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;

class CRD{
public:
	CRD(int _x, int _y)
		: x(_x), y(_y)
	{	}
	int x,y;
};

std::vector<int> REST;
std::vector<CRD> STAR;
int N;
int M;
bool compareZZ(CRD A, CRD B)
{
	if ( A.x < B.x )
		return true;
	else
		return false;
}

int main()
{
	scanf("%d%d",&N,&M);

	for (int i = 0 ; i < N ; i++)
	{
		int tmpX, tmpY;
		scanf("%d%d", &tmpX, &tmpY);
		STAR.push_back( CRD(tmpX, tmpY) );
	}

	std::sort(STAR.begin(), STAR.end(), compareZZ);


	for ( int i = 0 ; i < M ; i++)
	{
		int tmpX;
		scanf("%d", &tmpX);
		REST.push_back(tmpX);
	}

	for ( int i = 0 ; i < M ; i ++)
	{
		int pos = REST[i]; 
		std::vector<CRD> STARTMP;
		for ( int j = 0 ; j < N ; j++)
		{
			if ( pos < STAR[j].x )
				STARTMP.push_back(STAR[j]);
		}
		if ( STARTMP.size() == 0 )
		{
			printf("0.0000000\n");
			continue;
		}
		
		double tmpMax = STARTMP[0].y/(STARTMP[0].x - (double)pos );
		for ( int j = 1 ; j < STARTMP.size() ; j++)
		{
			if ( tmpMax < (STARTMP[j].y/(STARTMP[j].x - (double)pos)) )
				tmpMax = (STARTMP[j].y/(STARTMP[j].x - (double)pos));
			
		}
//		printf("pos: %d, tan : %.7lf\n", pos, tmpMax);
		
		double Result = atan(tmpMax);
		printf("%.7lf\n", Result);
	}


	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1000 ms 4980 KB Program timed out
2 Halted 0 ms 0 KB -