Official

A - Potions Editorial by en_translator


For beginners

This problem asks to use for statements. If you want to know how to use a for statement, see the article in APG4b (Japanese).

The following is the sample codes in C++ and Python.

  • Sample code (C++)
#include <iostream>
using namespace std;
int main() {
  int N, H, X, P[111];
  cin >> N >> H >> X;
  for (int n = 1; n <= N; n++) cin >> P[n];
  for (int n = 1; n <= N; n++) {
    if (H + P[n] >= X) {
      cout << n << endl;
      break;
    }
  }
}
  • Sample code (Python)
N, H, X = map(int, input().split())
P = [*map(int, input().split())]
for n in range(N):
    if H+P[n] >= X:
        print(n+1)
        exit(0)

posted:
last update: