A. Vanya and Fence
Problem Link: [Codeforces 677A##link##]
- [tab]
- JAVA
import java.util.Scanner; public class Main { public static void main(String[] args) { System.out.println(new Solution().Solve()); } } class Solution { static int count; public int getCount(){ return count; } public int Solve(){ Scanner s = new Scanner(System.in); int n = s.nextInt(), h = s.nextInt(); int[] arr = new int[n]; for(int i = 0; i < n; i++){ arr[i] = s.nextInt(); } for (int value : arr) { if (value > h) { count += 2; } else count += 1; } return getCount(); } }
- C++
#include <bits/stdc++.h> using namespace std; int n,h,a[200001],ans; int main() { cin>>n>>h; for(int i=1;i<=n;i++){ cin>>a[i]; } for(int i=1;i<=n;i++){ if(a[i]<=h) ans+=1; else ans+=2; } cout<<ans; }
- Python 3
h = int(input().split()[1]) h_s = input().split() print(sum([(int(int(i)>h) + 1) for i in h_s]))