diff --git a/zeta_python/completed/11000.py b/zeta_python/completed/11000.py new file mode 100644 index 0000000..86f830e --- /dev/null +++ b/zeta_python/completed/11000.py @@ -0,0 +1,23 @@ +import sys +import heapq + +input = sys.stdin.readline + + +def solve(N, Cl): + Cl.sort() + + pq = [] + heapq.heappush(pq, Cl[0][1]) + for i in range(1, N): + if pq[0] <= Cl[i][0]: + heapq.heappop(pq) + heapq.heappush(pq, Cl[i][1]) + + return len(pq) + + +if __name__ == "__main__": + N = int(input()) + Cl = [tuple(map(int, input().split())) for _ in range(N)] + print(solve(N, Cl)) diff --git a/zeta_python/completed/1326.py b/zeta_python/completed/1326.py new file mode 100644 index 0000000..6473a68 --- /dev/null +++ b/zeta_python/completed/1326.py @@ -0,0 +1,38 @@ +def solve(N, P, a, b): + a -= 1 + b -= 1 + D = [] + D.append((a, 0)) + visited = [2147483647] * N + visited[a] = 0 + if b == a: + return 0 + while D: + now, cost = D.pop(0) + + if now == b: + return cost + + from_now_on = now - P[now] + # - dir + while from_now_on >= 0: + if visited[from_now_on] > cost + 1: + visited[from_now_on] = cost + 1 + D.append((from_now_on, cost + 1)) + from_now_on -= P[now] + from_now_on = now + P[now] + # + dir + while from_now_on < N: + if visited[from_now_on] > cost + 1: + visited[from_now_on] = cost + 1 + D.append((from_now_on, cost + 1)) + from_now_on += P[now] + + return -1 + + +if __name__ == "__main__": + N = int(input()) + P = list(map(int, input().split())) + a, b = map(int, input().split()) + print(solve(N, P, a, b))