백준 2428 - 표절

백준 2428 - 표절

https://www.acmicpc.net/problem/2428

★ 풀이

처음엔 1번 방식과 같이 일일이 탐색하는 방법을 떠올렸지만, 시간복잡도가 O(N!) 이므로 주어진 문제는 시간내에 풀지 못한다는것을 인지했다. 따라서 이분탐색으로 각각의 Case별로 적절한 index값을 return 하도록 만들어서 해결했다.

★ 소스 코드

import java.io.*; import java.util.*; public class Main { static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); static int n; static int[] fSize; public static void main(String[] args) throws IOException { n = Integer.parseInt(br.readLine()); fSize = new int[n]; StringTokenizer st = new StringTokenizer(br.readLine()); for(int i = 0; i= fSize[mid] * 0.9) { ret = mid; left = mid + 1; }else { right = mid - 1; } } return ret; } }

from http://sweet-smell.tistory.com/132 by ccl(A) rewrite - 2021-12-04 15:02:01