Skip to content

Instantly share code, notes, and snippets.

@uchidama
Last active September 8, 2021 15:17
Show Gist options
  • Save uchidama/a688236b1423e02a4be440e6c99cd033 to your computer and use it in GitHub Desktop.
Save uchidama/a688236b1423e02a4be440e6c99cd033 to your computer and use it in GitHub Desktop.
AtCoder Beginner Contest 214 [ C - Distribution ] https://atcoder.jp/contests/abc214/tasks/abc214_c
'''
[問題]
https://atcoder.jp/contests/abc214/tasks/abc214_c
[参考]
https://atcoder.jp/contests/abc214/editorial/2438
 円周上を2周させないと答えが出ないとのこと
'''
import sys
sys.setrecursionlimit(10 ** 6) # 再帰上限の引き上げ
input = sys.stdin.readline
INF = 2 ** 63 - 1
N = int(input())
S = list(map(int, input().split()))
T = list(map(int, input().split()))
ans = [0] * N
ans[0] = T[0] # 最初のすぬけ君は、高橋君からもらう
# ループは円を2周する
for i in range(1, N*2):
# 隣のすぬけ君 -> すぬけ君から渡される時間、自分担当の高橋くんから渡される時間のどちらかの小さいほうが答え
ans[i%N] = min(ans[(i-1)%N] + S[(i-1)%N], T[i%N])
# 答えを表示
for a in ans:
print(a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment