公式

A - 合格者への拍手 / Applause for the Successful Candidates 解説 by kyopro_friends


初心者の方へ


問題文の指示通り、 \(P_1,\ldots,P_N\) のうち \(K\) 以上のものの合計を求めればよいです。

実装例 (C++)

#include<bits/stdc++.h>
using namespace std;

int main(){
  int n, k;
  cin >> n >> k;
  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] >= k){
      ans += a[i];
    }
  }
  cout << ans << endl;
}

実装例 (Python)

N, K = map(int, input().split())
A = list(map(int, input().split()))

ans = 0
for a in A:
  if a >= K:
    ans += a
print(ans)

投稿日時:
最終更新: