公式
		
		
			
		
		
			
	
B - Potions 解説 by en_translator
For beginners
- If you are new to learning programming and do not know where to start, please try Problem A "Welcome to AtCoder" from practice contest.  There you can find a sample code for each language.  
 
- Also, if you are not familiar with problems in programming contests, we recommend you to try some problems in "AtCoder Beginners Selection".  
 
- 「C++入門 AtCoder Programming Guide for beginners (APG4b)」 is a C++ tutorial for competitive programmers.  Sadly, this is only in Japanese too.
 
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)
				投稿日時:
				
				
				最終更新: