Official
A - G1 Editorial 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.
- 「Python入門 AtCoder Programming Guide for beginners (APG4bPython)」 is a Python tutorial for competitive programmers. Again, this is only in Japanese.
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: