公式
A - 合格ライン / Passing Score 解説
by
A - 合格ライン / Passing Score 解説
by
kyopro_friends
初心者の方へ
- AtCoder をはじめたばかりで何をしたらよいか分からない方は、まずは practice contest の問題A「Welcome to AtCoder」を解いてみてください。基本的な入出力の方法が載っています。
- また、プログラミングコンテストの問題に慣れていない方は、AtCoder Beginners Selection の問題をいくつか解いてみることをおすすめします。
- C++入門 AtCoder Programming Guide for beginners (APG4b) は、競技プログラミングのための C++ 入門用コンテンツです。
- Python入門 AtCoder Programming Guide for beginners (APG4bPython) は、競技プログラミングのための Python 入門用コンテンツです。
問題文中の指示通り、 \(A_1, \dots, A_N\) それぞれに対し、 \(X\) 未満であるかどうかを判定し、個数を数えればよいです。
実装例 (C++)
#include<bits/stdc++.h>
using namespace std;
int main(){
int n, x;
cin >> n >> x;
vector<int>a(n);
for(int i=0; i<n; i++) cin >> a[i];
int ans = 0;
for(int i=0; i<n; i++){
if(a[i] < x){
ans++;
}
}
cout << ans << endl;
}
実装例 (Python)
N, X = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
for a in A:
if a < X:
ans += 1
print(ans)
投稿日時:
最終更新:
