0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Polaris.AI プログラミングコンテスト 2026(AtCoder Beginner Contest 457)の解答等の速報的まとめ

A問題

そのまま

A
n = int(input())
a = list(map(int, input().split()))
print(a[int(input()) - 1])

B問題

各行に個数を示す数字が入っていることに気を付ける

B
n = int(input())
a = [list(map(int, input().split())) for _ in range(n)]
x, y = map(lambda x:int(x) - 1, input().split())
print(a[x][y + 1])

C問題

何個繋げることになるか計算して$K$から引いていく

C
n, k = map(int, input().split())
l, a = list(), list()
for _ in range(n):
    l_i, *a_i = map(int, input().split())
    l.append(l_i)
    a.append(a_i)
c = list(map(int, input().split()))

k -= 1

for l_i, a_i, c_i in zip(l, a, c):
    if k < l_i * c_i:
        print(a_i[k % l_i])
        exit()
    else:
        k -= l_i * c_i

D問題

答えで二分探索

D
n, k = map(int, input().split())
a = list(map(int, input().split()))

def check(target):
    cnt = 0
    for i, a_i in enumerate(a, 1):
        cnt += max(0, (target - a_i + i - 1) // i)
    return cnt <= k


ok, ng = 0, 3 * 10 ** 18
while abs(ok - ng) > 1:
    mid = (ok + ng) // 2
    if check(mid):
        ok = mid
    else:
        ng = mid

print(ok)
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?