๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
Algorithm

[Codeforces] 677A: Vanya and Fence

by ์ฃผ๋ฐœ2 2020. 3. 1.
๋ฐ˜์‘ํ˜•

https://codeforces.com/problemset/problem/677/A

 

Problem - 677A - Codeforces

 

codeforces.com

์ฝ”๋“œ

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int h = scan.nextInt();
		int[] arr = new int[n];
		int sum = 0;
		for(int i=0; i<n; i++) {
			arr[i] = scan.nextInt();
			sum += (arr[i] <= h) ? 1 : 2 ;
		}
		System.out.println(sum);
		scan.close();
	}

}

ํ’€์ด

์ฃผ์–ด์ง„ h(๋†’์ด)๋ณด๋‹ค ์‚ฌ๋žŒ์˜ ๋†’์ด๋ณด๋‹ค ์ž‘๊ฑฐ๋‚˜ ๊ฐ™์œผ๋ฉด 1์„ ๋”ํ•˜๊ณ , ํฌ๋ฉด 2๋ฅผ ๋”ํ•œ๋‹ค.

 

๋ฐ˜์‘ํ˜•

๋Œ“๊ธ€