Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 완전탐색
- 코딩테스트
- docker
- python
- Kubernetes
- rnn
- GCP
- GIT
- DeepLearning
- github
- 알고리즘
- GitHub Action
- PytorchLightning
- torchserve
- pep8
- datascience
- NLP
- 백준
- NaverAItech
- leetcode
- 네이버AItech
- vscode
- FastAPI
- Kaggle
- autoencoder
- FDS
- wandb
- pytorch
- 프로그래머스
- Matplotlib
Archives
- Today
- Total
Sangmun
binary search left & right 본문
https://www.acmicpc.net/problem/10816
10816번: 숫자 카드 2
첫째 줄에 상근이가 가지고 있는 숫자 카드의 개수 N(1 ≤ N ≤ 500,000)이 주어진다. 둘째 줄에는 숫자 카드에 적혀있는 정수가 주어진다. 숫자 카드에 적혀있는 수는 -10,000,000보다 크거나 같고, 10,
www.acmicpc.net
from bisect import bisect_left, bisect_right
from sys import stdin
n = stdin.readline().rstrip()
card = list(map(int,stdin.readline().split()))
m = stdin.readline().rstrip()
test = list(map(int,stdin.readline().split()))
card.sort()
def count_by_range(a, left_value, right_value):
right_index = bisect_right(a, right_value)
left_index = bisect_left(a, left_value)
return right_index - left_index
for i in range(len(test)):
print(count_by_range(card, test[i], test[i]), end=' ')
Comments