Official

A - G1 Editorial by en_translator


For beginners

Whether a \(K\)-year-old horse can participate in the \(i\)-th race can be determined by checking whether \(K \le A_i\) using an if statement.
To check this for all races, we can use a for statement.

In this problem, you are first given all values of \(A_i\), and then \(K\), so \(A\) must be stored in a temporal list or an array.

Sample code (C++):

#include<bits/stdc++.h>

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(auto &nx : A){
    cin >> nx;
  }
  int K;
  cin >> K;
  int res=0;
  for(auto &nx : A){
    if(K<=nx){res++;}
  }
  cout << res << "\n";
  return 0;
}

posted:
last update: