Skip to content

센티와 마법의 뿅망치 #4

@ghrnwjd

Description

@ghrnwjd

@yeeun426

내 생각에 이쪽 부분이 문제인 거 같음.
거인의 나라의 인구수 N (1 ≤ N ≤ 10^5)과 센티의 키를 나타내는 정수 H(1 ≤ H ≤ 2 × 10^9), 마법의 뿅망치의 횟수 제한 T (1 ≤ T ≤ 10^5)가 빈칸을 사이에 두고 주어진다. 라고 문제에 나와 있음 .

let tallest = Math.max(...height);
let tallIndex = height.indexOf(tallest);

이 코드보면

  1. Math.max로 항상 배열한바퀴 다돌아야 됨. 최대 O(n) -> 10^5
  2. 뿅망치도 10^5 번 때릴 수 있으므로 -> 10^5 * 10^5 = 10^10 = 10,000,000,000
  3. 최대 100억번 돌아야 됌 .

--> 뿅망치 횟수를 줄일 수 없기 때문에 배열을 1번을 수정하면 고칠 수 있을 거 같다는 생각이 뭔가 듬.

https://github.com/Algorithm-Study-ICE/algorithm-study-ICE/blob/main/Week/week6/BOJ_%EC%84%BC%ED%8B%B0%EC%99%80%EB%A7%88%EB%B2%95%EC%9D%98%EB%BF%85%EB%A7%9D%EC%B9%98_yeeun.js

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions