1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【ABC410 A問題】考察から実装(c++)まで

Last updated at Posted at 2025-06-17

AtCoderBeginnerContest410の解説&感想です。
コンテストリンク

問題一覧

A問題 - G1

問題リンク

問題概要

整数$N,K$と、数列$(A_1,A_2,...,A_N)$が入力される。
$A_i \le K$となる$i$の個数を求めよ。

制約

  • $1 \le N \le 100$
  • $1 \le K \le 100$
  • $1 \le A_i \le 100$

考察

A問題なので$N$の制約が小さいので、言われた通りに$A_i$を全部チェックすれば良さそう。
計算量は$O(N)$。

実装

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;

int main(){
    //入力
    ll N;
    cin>>N;
    
    vll A(N);
    for(int i=0;i<N;i++) cin>>A[i];
    
    ll K;
    cin>>K;
    
    
    //Aを全部見て、K <= A_i の数を数える
    ll cnt = 0;
    for(int i=0;i<N;i++) cnt += (K <= A_i);
    
    cout<<cnt<<endl;
}

他の問題

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?