
エントリーの編集

エントリーの編集は全ユーザーに共通の機能です。
必ずガイドラインを一読の上ご利用ください。
A - Repeat ACL, B - Balance, C - Exam and Wizard - Qiita
記事へのコメント0件
- 注目コメント
- 新着コメント
このエントリーにコメントしてみましょう。
注目コメント算出アルゴリズムの一部にLINEヤフー株式会社の「建設的コメント順位付けモデルAPI」を使用しています

- バナー広告なし
- ミュート機能あり
- ダークモード搭載
関連記事
A - Repeat ACL, B - Balance, C - Exam and Wizard - Qiita
N = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) total = ... N = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) total = 0 total_BtoA = 0 total_AtoB = 0 total_AtoB_0 = 0 C = [] for i in range(0, N): if B[i] > A[i]: total_BtoA+=1 total += B[i] - A[i] elif B[i] < A[i]: C.append(A[i] - B[i]) else: total_AtoB_0 += 1 C.sort(reverse=True) for i in range(0, len(C)): if total >=0: total -= C[i] total_AtoB+=1 if total>0: print(-1