## A - Not Too Hard Editorial by en_translator

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” (https://atcoder.jp/contests/abs).

Follow the instruction in the problem statement to write code that inspects the scores of all the problem and find the sum of those less than or equal to \(X\).
To scan the scores of all the problem \(S_1, S_2, \ldots, S_N\), one can use a basic feature of a programming language: the **loop** structure (like a for statement);
to check if the score of a problem is \(X\) or less, one can use another basic feature of a programming language: the **conditional branch** (like a if statement).

The following is sample code of this problem in C++ language.

```
#include <iostream>
using namespace std;
int main(void)
{
int n, x, s[8];
cin >> n >> x;
for(int i = 0; i < n; i++) cin >> s[i];
int ans = 0;
for(int i = 0; i < n; i++) if(s[i] <= x) ans += s[i];
cout << ans << endl;
return 0;
}
```

posted:

last update: