8000 solve 0x13 12015 · jo0n-lab/basic-algo-lecture@3af3715 · GitHub
[go: up one dir, main page]

Skip to content

Commit < 8000 span class="text-mono bgColor-muted rounded p-1">3af3715

Browse files
author
cuberry
committed
solve 0x13 12015
1 parent fdeb2b9 commit 3af3715

File tree

15 files changed

+86
-53
lines changed

15 files changed

+86
-53
lines changed

0x13/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
결정 문제: 랜선의 길이가 X일 때, 랜선이 N개 이상인가 아닌가?
33

44

5-
lower bound: 찾고자 하는 값 이상이 처음 나타나는 위치
6-
upper bound: 찾고자 하는 값 초과가 처음 나타나는 위치
5+
* lower bound: 찾고자 하는 값 이상이 처음 나타나는 위치
6+
* 값을 포함하는지 아닌지 경계값에 대한 이해 필요
7+
* upper bound: 찾고자 하는 값 초과가 처음 나타나는 위치

0x13/lower_bound/main

-24 KB
Binary file not shown.

0x13/lower_bound/main.cc

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,30 @@
11
#include<bits/stdc++.h>
22
using namespace std;
33

4+
int N,K;
45
int arr[102];
5-
int N,target;
66

77
int main(){
8-
ios::sync_with_stdio(false);
9-
cin.tie(NULL);
10-
118
cin>>N;
129
for(int i=1;i<=N;i++)
1310
cin>>arr[i];
14-
sort(arr+1,arr+N+1);
15-
cin>>target;
16-
11+
cin>>K;
1712

1813
int st=1;
1914
int en=N;
2015
int mid;
2116
while(st<en){
2217
mid=(st+en)/2;
23-
if(arr[mid]<target)
24-
st=mid+1;
25-
else
18+
if(K<=arr[mid])
2619
en=mid;
20+
else
21+
st=mid+1;
2722
}
28-
cout<<arr[mid]<<" "<<mid;
23+
24+
cout<<st;
2925
}
26+
27+
3028

3129

32-
3330

0x13/solutions/10816_1.cpp renamed to 0x13/lower_bound/sol.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// Authored by : BaaaaaaaaaaarkingDog
2-
// Co-authored by : -
31
// http://boj.kr/e78b47fa3e08436faada666bafcf9501
42
#include <bits/stdc++.h>
53
using namespace std;
@@ -42,4 +40,4 @@ int main(void) {
4240
cin >> t;
4341
cout << upper_idx(t,n)-lower_idx(t,n) << '\n';
4442
}
45-
}
43+
}

0x13/lower_bound/tc1

Lines changed: 0 additions & 3 deletions
This file was deleted.

0x13/lower_bound/tc2

Lines changed: 0 additions & 3 deletions
This file was deleted.

0x13/lower_bound/tc3

Lines changed: 0 additions & 3 deletions
This file was deleted.

0x13/lower_bound/tc4

Lines changed: 0 additions & 3 deletions
This file was deleted.

0x13/solutions/10816.cpp

Lines changed: 0 additions & 23 deletions
This file was deleted.

0x13/solutions/12015.cpp renamed to 0x13/v12015/12015.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ int main(void){
88
ios::sync_with_stdio(0);
99
cin.tie(0);
1010

11-
}
11+
}

0 commit comments

Comments
 (0)
0