[백준 BOJ 10816번] 숫자 카드 2 (C++ )


[백준 BOJ 10816번] 숫자 카드 2 (C++ )

#include<iostream> #include<algorithm> using namespace std; int find_result(int* arr1,int find_num,int start,int end) { int count = 0; int tmp; while (start <= end) { int mid = (start + end)/2; if (arr1[mid] == find_num) { count++; tmp = mid+1; while (tmp <end &&arr1[tmp] ==find_num) { count++; tmp++; } tmp = mid -1; while (0<= tmp && arr1[tmp] == find_num) { count++; tmp--; } return (count); } else if (arr1[mid]>find_num) end = mid - 1; else start=mid+1; } return (0); } int main() { ios ::sync_...



원문링크 : [백준 BOJ 10816번] 숫자 카드 2 (C++ )