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 50Output example 1
4Input example 2
3 100
10 10 10Output example 2
-1What you'll train
Cover the edge cases
What you get
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つだけ見て、弱点・指示の穴・改善例を返します。
テストに落ちていてもレビューできます。落ちた理由と、指示に足りなかった情報を結びつけます。