https://www.acmicpc.net/problem/1072
import sys
input = sys.stdin.readline
x, y = map(int, input().split())
z = int(100 * y / x)
if z >= 99:
print(-1)
else:
ans = 0
start = 0
end = 1000000000
while(start <= end):
mid = (start + end) // 2
if int(100 * (y + mid) / (x + mid)) <= z:
start = mid + 1
else:
end = mid - 1
print(end + 1)
https://www.acmicpc.net/problem/1654
# λμ μ κΈΈμ΄ κ΅¬νκΈ°
# λμ μ κΈΈμ΄ μμ§μ¬ λμ κ°μ μ±μ°λμ§ λ³΄κΈ°
k, n = map(int, input().split())
lan = [int(input()) for _ in range(k)]
start = 1
end = max(lan)
while(start <= end):
mid = (start + end) // 2
count = 0
for i in lan:
count += (i // mid)
if count >= n:
start = mid + 1
result = mid
else:
end = mid - 1
print(result)
https://www.acmicpc.net/problem/1920
import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
a.sort()
result = []
for i in b:
start = 0
end = n - 1
flag = 0
while(start <= end):
mid = (start + end) // 2
if i < a[mid]:
end = mid - 1
elif i > a[mid]:
start = mid + 1
elif i == a[mid]:
flag = 1
break
result.append(flag)
for i in result:
print(i)
μ΄ λ¬Έμ λ ν΄μλ‘λ ν΄κ²°κ°λ₯νλ€. κ²μμ΄ μ©μ΄ν ν΄μ!
import sys
input = sys.stdin.readline
n = map(int, input())
a = list(map(int, input().split()))
pool = {}
for k in a:
pool[k] = 1
m = map(int, input())
b = list(map(int, input().split()))
for t in b:
if t in pool:
print(1)
else:
print(0)
https://www.acmicpc.net/problem/2512
import sys
input = sys.stdin.readline
n = int(input())
bud = list(map(int, input().split()))
m = int(input())
start = 1
end = max(bud)
while(start <= end):
count = 0
mid = (start + end) // 2
for i in bud:
if i <= mid:
count += i
else:
count += mid
if count <= m:
start = mid + 1
else:
end = mid - 1
print(end)
728x90
'Algorithms > Algorithms' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
μ μ°ΎκΈ° (λ°±μ€ 1920λ², ν΄μ) (0) | 2021.11.04 |
---|---|
1λ‘λ§λ€κΈ° (λ°±μ€1463) (0) | 2021.10.13 |
μμ΄ μ¬μ΄ν΄ (λ°±μ€ 10451) (0) | 2021.10.12 |
μ°κ²°μμμκ°μ (λ°±μ€ 11724) (0) | 2021.10.12 |
μ΄λΆ κ·Έλν (λ°±μ€ 1707) (0) | 2021.10.08 |