Official

A - Counting Passes Editorial by physics0523


初心者の方へ
  • プログラミングの学習を始めたばかりで何から手をつけるべきかわからない方は、まずは practice contest の問題A「Welcome to AtCoder」をお試しください。言語ごとに解答例が掲載されています。
  • また、プログラミングコンテストの問題に慣れていない方は、 AtCoder Beginners Selection の問題をいくつか試すことをおすすめします。
  • C++入門 AtCoder Programming Guide for beginners (APG4b) は、競技プログラミングのための C++ 入門用コンテンツです。

この問題は、ループによって全参加者の得点を読み込み、それぞれ \(L\) 以上であるかどうか判断することで正解できます。

実装例 (Python):

n,l = map(int,input().split())
a = list(map(int,input().split()))
ok = 0

for x in a:
    if x >= l:
        ok += 1

print(ok)

実装例 (C++):

#include<bits/stdc++.h>

using namespace std;

int main(){
  int n,l;
  cin >> n >> l;
  int ok=0;
  for(int i=0;i<n;i++){
    int a;
    cin >> a;
    if(a>=l){ok++;}
  }
  cout << ok << "\n";
  return 0;
}

posted:
last update: