C++ 363

[C/C++] programmers Level 0 평행

코드 #include using namespace std; int solution(vector dots) { int answer = 0; // 점 네개로 두개 씩 이었을 경우 -> 경우의 수 세 가지 연산 후 비교 // abs를 이요한 연산에 if(x1==x2 && y1==y2)는 시간초과 double x1=dots[0][0]-dots[1][0]; double y1=dots[0][1]-dots[1][1]; double x2=dots[2][0]-dots[3][0]; double y2=dots[2][1]-dots[3][1]; if(x1/y1 == x2/y2){ return 1; } x1=dots[0][0]-dots[2][0]; y1=dots[0][1]-dots[2][1]; x2=dots[1][0]-dots[..

[C/C++] programmers Level 3 단속카메라 (복습)

코드 #include #include // sort using namespace std; int solution(vector routes) { int answer = 1; // 기본 카메라 1대 sort(routes.begin(), routes.end()); // 오름 차순 정렬 int check = routes[0][1]; // 현재 차가 나가는 시점 for(const auto& r : routes){ if(checkr[1]){ // 현재 차가 나가는 시점이 뒤 차가 나가는 시점보다 클 때 check=r[1]; // 뒤 차가 나가는 시점으로 정정 } } return answer; }