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

Problem 40: Maximum Sum of Two Adjacent Elements

An integer N is given on the first line, and N integers separated by single spaces are given on the second line. Output, on one line, the largest value obtained by adding two adjacent elements.

For example, for 1 2 3 4 5, the sums of adjacent pairs are 3, 5, 7, 9, so the answer is 9.

Constraints

2 ≤ N ≤ 100, 0 ≤ each element ≤ 1000

Input example 1

5
1 2 3 4 5

Output example 1

9

Input example 2

3
10 1 10

Output example 2

11

What you'll train

Cover the edge cases

What you get

  • Define what counts as an adjacent pair
  • Check boundary values
  • Specify the output format

How to ask the AI

Tell the AI specifically that it should compare the sums of two adjacent elements. Since no adjacent pair exists when N is 1, it's also reassuring to confirm how the program should behave in that case.

If you ask vaguelyThe AI may not account for the case N=1, where no adjacent pair exists, resulting in code that errors out or returns an incorrect value.

あなたのコード

実行しました

プレビュー

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

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

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