일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- off by one
- heap
- 브루트 포스
- DFS
- 수학
- 연결리스트
- 백트래킹
- 이진트리
- BFS
- 문자열 처리
- 큐
- 포맷스트링버그
- 이진 탐색
- BOF
- 다이나믹 프로그래밍
- 투 포인터
- 이분 탐색
- fsb
- 분할 정복
- OOB
- tcache
- 스택
- 스위핑 알고리즘
- House of Orange
- RTL
- syscall
- 동적 계획법
- 완전 탐색
- 에라토스테네스의 체
- ROP
Archives
- Today
- Total
SDJ( 수돈재 아님 ㅎ )
[C++] 10815 - 숫자 카드 본문
문제 링크 : https://www.acmicpc.net/problem/10815
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
int A[500005];
int N, M;
bool bisearch(int find)
{
int left = 0;
int right = N-1;
int mid;
while(left <= right)
{
mid = (left + right)/2;
if(A[mid] == find)
return true;
else if(A[mid] > find)
right = mid-1;
else if(A[mid] < find)
left = mid+1;
}
return false;
}
int main(void)
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int tmp;
cin >> N;
for(int i = 0; i < N; ++i)
cin >> A[i];
sort(A, A+N);
cin >> M;
for(int i = 0; i < M; ++i)
{
cin >> tmp;
cout << bisearch(tmp) << ' ';
}
return 0;
}
|
'알고리즘 > Backjoon' 카테고리의 다른 글
[C++] 1780 - 종이의 개수 (0) | 2020.01.23 |
---|---|
[C++] 1158 - 요세푸스 문제 (0) | 2020.01.23 |
[C++] 2805 - 나무 자르기 (0) | 2020.01.23 |
[C++] 1920 - 수 찾기 (0) | 2020.01.23 |
[C++] 9421 - 소수상근수 (0) | 2020.01.20 |
Comments