Skip to content

Commit 5f4ba0a

Browse files
committed
Lv3_기지국설치
1 parent 083900f commit 5f4ba0a

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include <iostream>
2+
#include <vector>
3+
using namespace std;
4+
5+
int solution109(int n, vector<int> stations, int w)
6+
{
7+
int answer = 0;
8+
int index = 0;
9+
10+
for (int i = 1; i <= n; i++) {
11+
if (index<stations.size() && i >= stations[index] - w) {
12+
i = stations[index] + w;
13+
index++;
14+
}
15+
else {
16+
i += (2 * w);
17+
if (i > n)
18+
i = n;
19+
answer++;
20+
}
21+
}
22+
23+
return answer;
24+
}

Programmers/Programmers.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@
9898
<ClCompile Include="Lv3\Lv3_가장긴펠린드롬.cpp" />
9999
<ClCompile Include="Lv3\Lv3_가장먼노드.cpp" />
100100
<ClCompile Include="Lv3\Lv3_거스름돈.cpp" />
101+
<ClCompile Include="Lv3\Lv3_기지국설치.cpp" />
101102
<ClCompile Include="Lv3\Lv3_네트워크.cpp" />
102103
<ClCompile Include="Lv3\Lv3_단속카메라.cpp" />
103104
<ClCompile Include="Lv3\Lv3_단어변환.cpp" />

Programmers/Programmers.vcxproj.filters

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,5 +348,8 @@
348348
<ClCompile Include="Lv3\Lv3_최고의집합.cpp">
349349
<Filter>소스 파일</Filter>
350350
</ClCompile>
351+
<ClCompile Include="Lv3\Lv3_기지국설치.cpp">
352+
<Filter>소스 파일</Filter>
353+
</ClCompile>
351354
</ItemGroup>
352355
</Project>

0 commit comments

Comments
 (0)