Skip to content

Commit

Permalink
unsolved 기지국설치 - 0ms 0mb
Browse files Browse the repository at this point in the history
  • Loading branch information
Eundms committed Jan 24, 2025
1 parent 74b39e9 commit 63c2bed
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 21 deletions.
22 changes: 22 additions & 0 deletions Programmers/기지국설치/기지국설치_박은정.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
class Solution {
public int solution(int n, int[] stations, int w) {
int answer = 0;

int apt = 1;
for(int i = 0; i < stations.length; i++) {
int start = stations[i] - w;
int end = stations[i] + w;
if(apt < start) {
answer += build(start-apt, w);
}
apt = end + 1; // 커버되지 않은 아파트
}
if(apt <= n) {
answer += build(n-apt+1, w); // n까지의 모든 아파트를 포함해야 하므로 + 1
}
return answer;
}
static int build(int dist, int w) {
return dist / (2 * w + 1) + (dist % (2 * w + 1) > 0 ? 1 : 0);
}
}
21 changes: 0 additions & 21 deletions Programmers/등대/산모양타일링/산모양타일링_김인호

This file was deleted.

0 comments on commit 63c2bed

Please sign in to comment.