티스토리 뷰
728x90
문제 링크
https://www.acmicpc.net/problem/15780
대충 계산해보자.
구의 수 |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
꽃는 수 |
1 |
1 |
2 |
2 |
3 |
3 |
4 |
구의 수를 x라 하면, 꽃을 수 있는 수는 x+12 이다.
정답 코드
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int n, k; | |
int main() { | |
cin >> n >> k; | |
while (k--) { | |
int x; | |
cin >> x; | |
n -= ((x + 1) / 2); | |
} | |
if (n <= 0) cout << "YES"; | |
else cout << "NO"; | |
} |
728x90
'알고리즘 > 문제 풀이' 카테고리의 다른 글
[2018 IUPC] 백준 15782 Calculate! 2 (4) | 2018.06.29 |
---|---|
[2018 IUPC] 백준 15781 헬멧과 조끼 (0) | 2018.06.29 |
[BOJ] 백준 5214 환승 (3) | 2018.06.29 |
[BOJ] 백준 1008 A/B (0) | 2018.06.28 |
[BOJ] 백준 1005 ACM Craft (0) | 2018.06.28 |
댓글