CodeDrill
day_streak: --
← 問題一覧に戻る
Python ・ Standard I/O

Problem 58: The Day Savings Reach the Goal

An integer N (number of days) and G (target amount) are given on the first line, separated by a space. N integers (the amount saved each day) are given on the second line. Output the day on which the total savings first reaches G or more (counting from day 1). If the target is not reached even after N days, output -1.

Constraints

1 ≤ N ≤ 100, 1 ≤ G ≤ 100000, 0 ≤ each daily savings amount ≤ 1000

Input example 1

5 100
20 30 10 40 50

Output example 1

4

Input example 2

3 100
10 10 10

Output example 2

-1

What you'll train

Cover the edge cases

What you get

  • Specify the output for the not-reached case
  • Instruct on cumulative processing
  • Define the first day the target is reached

How to ask the AI

Tell the AI that if the target amount is not reached even after N days, -1 should be output, and that the day the cumulative total first reaches G or more should be counted starting from day 1.

If you ask vaguelyForgetting to write the handling for the case where the target isn't reached, resulting in an error or 0 being output.

あなたのコード

実行しました

プレビュー

AIレビュー(プロンプト練習)

コードはChatGPTやClaudeに出させたものを貼って構いません。
ここでの本番は「次にAIへ出す指示」です。評価軸は1つだけ見て、弱点・指示の穴・改善例を返します。
テストに落ちていてもレビューできます。落ちた理由と、指示に足りなかった情報を結びつけます。

先にコードを実行し、テストを1つ以上通してください。